Skip to content

Commit dc78bd0

Browse files
srikaaviyaxrmx
authored andcommitted
Fix pylint false positives for ThreadPoolExecutor (open-telemetry#4244)
* Bump pylint to 4.0.5 to fix Python 3.14 concurrent.futures false positives * Fix too-many-positional-arguments pylint failures - Add max-positional-arguments=10, Add pylint: disable=too-many-positional-arguments to functions that legitimately exceed the limit * Bump max-positional-arguments to 12 and remove unnecessary disable comments * Address review comments: fix CHANGELOG, remove stale pylintrc comment, add openai-agents disable * Fix formatting: restore blank line in CHANGELOG and remove extra blank line in .pylintrc * Update processor.py * Update test_botocore_bedrock.py --------- Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
1 parent 7edfc3a commit dc78bd0

File tree

12 files changed

+17
-25
lines changed

12 files changed

+17
-25
lines changed

.pylintrc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ persistent=yes
3737
# Specify a configuration file.
3838
#rcfile=
3939

40-
# When enabled, pylint would attempt to guess common misconfiguration and emit
41-
# user-friendly hints instead of false-positive error messages.
42-
suggestion-mode=yes
43-
4440
# Allow loading of arbitrary C extensions. Extensions are imported into the
4541
# active Python interpreter and may run arbitrary code.
4642
unsafe-load-any-extension=no
@@ -463,6 +459,9 @@ valid-metaclass-classmethod-first-arg=cls
463459
# Maximum number of arguments for function / method.
464460
max-args=5
465461

462+
# Maximum number of positional arguments for function / method.
463+
max-positional-arguments=12
464+
466465
# Maximum number of attributes for a class (see R0902).
467466
max-attributes=7
468467

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
1212
## Unreleased
1313

14+
### Added
15+
16+
- Bump `pylint` to `4.0.5`
17+
([#4244](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4244))
18+
1419
### Breaking changes
1520

1621
- Drop Python 3.9 support

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
pylint==3.0.2
1+
pylint==4.0.5
22
httpretty==1.1.4
33
pyright==v1.1.404
44
sphinx==7.1.2

instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/src/opentelemetry/instrumentation/openai_agents/span_processor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ def get_span_name(
426426
class GenAISemanticProcessor(TracingProcessor):
427427
"""Trace processor adding GenAI semantic convention attributes with metrics."""
428428

429+
# pylint: disable=too-many-positional-arguments
429430
def __init__(
430431
self,
431432
tracer: Optional[Tracer] = None,

instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ class OpenTelemetryMiddleware:
586586
exclude_spans: Optionally exclude HTTP `send` and/or `receive` spans from the trace.
587587
"""
588588

589-
# pylint: disable=too-many-branches
589+
# pylint: disable=too-many-branches,too-many-positional-arguments
590590
def __init__(
591591
self,
592592
app,

instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_run_coroutine_threadsafe.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
# limitations under the License.
1414
import asyncio
1515
import threading
16-
from concurrent.futures import ( # pylint: disable=no-name-in-module; TODO #4199
17-
ThreadPoolExecutor,
18-
)
16+
from concurrent.futures import ThreadPoolExecutor
1917
from unittest.mock import patch
2018

2119
# pylint: disable=no-name-in-module

instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,6 @@ def test_invoke_model_with_content(
14871487
finish_reason = "length"
14881488
else:
14891489
pytest.xfail("model family not handled: {model_family}")
1490-
return
14911490

14921491
assert_message_in_logs(logs[0], "gen_ai.user.message", user_content, span)
14931492

@@ -1628,7 +1627,6 @@ def test_invoke_model_with_content_different_events(
16281627
choice_content = [{"type": "text", "text": "This is a test"}]
16291628
else:
16301629
pytest.xfail("llm_model_value not handled: {llm_model_value}")
1631-
return
16321630

16331631
body = get_invoke_model_body(
16341632
llm_model_value,
@@ -2070,7 +2068,6 @@ def test_invoke_model_with_content_tool_call(
20702068
llm_model_config = AnthropicClaudeModel
20712069
else:
20722070
pytest.xfail("model family not handled: {model_family}")
2073-
return
20742071

20752072
invoke_model_tool_call(
20762073
span_exporter,
@@ -2156,7 +2153,6 @@ def test_invoke_model_no_content(
21562153
finish_reason = "length"
21572154
else:
21582155
pytest.xfail("model family not handled: {model_family}")
2159-
return
21602156

21612157
choice_body = {
21622158
"index": 0,
@@ -2190,7 +2186,6 @@ def test_invoke_model_no_content_different_events(
21902186
finish_reason = "end_turn"
21912187
else:
21922188
pytest.xfail("llm_model_value not handled: {llm_model_value}")
2193-
return
21942189

21952190
body = get_invoke_model_body(
21962191
llm_model_value,
@@ -2246,7 +2241,6 @@ def test_invoke_model_no_content_tool_call(
22462241
llm_model_config = AnthropicClaudeModel
22472242
else:
22482243
pytest.xfail("model family not handled: {model_family}")
2249-
return
22502244

22512245
invoke_model_tool_call(
22522246
span_exporter,
@@ -2401,7 +2395,6 @@ def test_invoke_model_with_response_stream_with_content(
24012395
}
24022396
else:
24032397
pytest.xfail("model family not handled: {model_family}")
2404-
return
24052398

24062399
choice_body = {
24072400
"index": 0,
@@ -2437,7 +2430,6 @@ def test_invoke_model_with_response_stream_with_content_different_events(
24372430
choice_content = [{"text": "This is a test", "type": "text"}]
24382431
else:
24392432
pytest.xfail("llm_model_value not handled: {llm_model_value}")
2440-
return
24412433

24422434
max_tokens = 10
24432435
body = get_invoke_model_body(
@@ -2672,7 +2664,6 @@ def test_invoke_model_with_response_stream_with_content_tool_call(
26722664
llm_model_config = AnthropicClaudeModel
26732665
else:
26742666
pytest.xfail("model family not handled: {model_family}")
2675-
return
26762667

26772668
invoke_model_with_response_stream_tool_call(
26782669
span_exporter,
@@ -2801,7 +2792,6 @@ def test_invoke_model_with_response_stream_no_content_different_events(
28012792
finish_reason = "end_turn"
28022793
else:
28032794
pytest.xfail("llm_model_value not handled: {llm_model_value}")
2804-
return
28052795

28062796
max_tokens = 10
28072797
body = get_invoke_model_body(
@@ -2864,7 +2854,6 @@ def test_invoke_model_with_response_stream_no_content_tool_call(
28642854
llm_model_config = AnthropicClaudeModel
28652855
else:
28662856
pytest.xfail("model family not handled: {model_family}")
2867-
return
28682857

28692858
invoke_model_with_response_stream_tool_call(
28702859
span_exporter,

instrumentation/opentelemetry-instrumentation-threading/tests/test_threading.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from __future__ import annotations
1616

1717
import threading
18-
from concurrent.futures import ( # pylint: disable=no-name-in-module; TODO #4199
18+
from concurrent.futures import (
1919
Future,
2020
ThreadPoolExecutor,
2121
)

instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ def _get_span_name(method: str) -> str:
424424
return method
425425

426426

427-
# pylint: disable=too-many-locals
427+
# pylint: disable=too-many-locals,too-many-positional-arguments
428428
def _instrument(
429429
tracer: Tracer,
430430
duration_histogram_old: Histogram,

processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
BaggageKeyPredicateT = Callable[[str], bool]
2424

2525
# A BaggageKeyPredicate that always returns True, allowing all baggage keys to be added to spans
26-
ALLOW_ALL_BAGGAGE_KEYS: BaggageKeyPredicateT = lambda _: True # noqa: E731
26+
ALLOW_ALL_BAGGAGE_KEYS: BaggageKeyPredicateT = lambda _: True # noqa: E731 # pylint:disable=invalid-name
2727

2828

2929
class BaggageSpanProcessor(SpanProcessor):

0 commit comments

Comments
 (0)