diff --git a/.pylintrc b/.pylintrc index 17f53f2098..d3a4723112 100644 --- a/.pylintrc +++ b/.pylintrc @@ -37,10 +37,6 @@ persistent=yes # Specify a configuration file. #rcfile= -# When enabled, pylint would attempt to guess common misconfiguration and emit -# user-friendly hints instead of false-positive error messages. -suggestion-mode=yes - # Allow loading of arbitrary C extensions. Extensions are imported into the # active Python interpreter and may run arbitrary code. unsafe-load-any-extension=no @@ -463,6 +459,9 @@ valid-metaclass-classmethod-first-arg=cls # Maximum number of arguments for function / method. max-args=5 +# Maximum number of positional arguments for function / method. +max-positional-arguments=12 + # Maximum number of attributes for a class (see R0902). max-attributes=7 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dca6b771e..8818f8b070 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Bump `pylint` to `4.0.5` + ([#4244](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4244)) + ### Breaking changes - Drop Python 3.9 support diff --git a/dev-requirements.txt b/dev-requirements.txt index 29325a6d35..28b7f81487 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,4 @@ -pylint==3.0.2 +pylint==4.0.5 httpretty==1.1.4 pyright==v1.1.404 sphinx==7.1.2 diff --git a/instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/src/opentelemetry/instrumentation/openai_agents/span_processor.py b/instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/src/opentelemetry/instrumentation/openai_agents/span_processor.py index 74be663701..55539a4931 100644 --- a/instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/src/opentelemetry/instrumentation/openai_agents/span_processor.py +++ b/instrumentation-genai/opentelemetry-instrumentation-openai-agents-v2/src/opentelemetry/instrumentation/openai_agents/span_processor.py @@ -426,6 +426,7 @@ def get_span_name( class GenAISemanticProcessor(TracingProcessor): """Trace processor adding GenAI semantic convention attributes with metrics.""" + # pylint: disable=too-many-positional-arguments def __init__( self, tracer: Optional[Tracer] = None, diff --git a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py index e28315f502..8e7106010f 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/src/opentelemetry/instrumentation/asgi/__init__.py @@ -586,7 +586,7 @@ class OpenTelemetryMiddleware: exclude_spans: Optionally exclude HTTP `send` and/or `receive` spans from the trace. """ - # pylint: disable=too-many-branches + # pylint: disable=too-many-branches,too-many-positional-arguments def __init__( self, app, diff --git a/instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_run_coroutine_threadsafe.py b/instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_run_coroutine_threadsafe.py index d612076dbf..fdf4bcb353 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_run_coroutine_threadsafe.py +++ b/instrumentation/opentelemetry-instrumentation-asyncio/tests/test_asyncio_run_coroutine_threadsafe.py @@ -13,9 +13,7 @@ # limitations under the License. import asyncio import threading -from concurrent.futures import ( # pylint: disable=no-name-in-module; TODO #4199 - ThreadPoolExecutor, -) +from concurrent.futures import ThreadPoolExecutor from unittest.mock import patch # pylint: disable=no-name-in-module diff --git a/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py b/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py index ef0146314f..bf8a2ac242 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/tests/test_botocore_bedrock.py @@ -1487,7 +1487,6 @@ def test_invoke_model_with_content( finish_reason = "length" else: pytest.xfail("model family not handled: {model_family}") - return assert_message_in_logs(logs[0], "gen_ai.user.message", user_content, span) @@ -1628,7 +1627,6 @@ def test_invoke_model_with_content_different_events( choice_content = [{"type": "text", "text": "This is a test"}] else: pytest.xfail("llm_model_value not handled: {llm_model_value}") - return body = get_invoke_model_body( llm_model_value, @@ -2070,7 +2068,6 @@ def test_invoke_model_with_content_tool_call( llm_model_config = AnthropicClaudeModel else: pytest.xfail("model family not handled: {model_family}") - return invoke_model_tool_call( span_exporter, @@ -2156,7 +2153,6 @@ def test_invoke_model_no_content( finish_reason = "length" else: pytest.xfail("model family not handled: {model_family}") - return choice_body = { "index": 0, @@ -2190,7 +2186,6 @@ def test_invoke_model_no_content_different_events( finish_reason = "end_turn" else: pytest.xfail("llm_model_value not handled: {llm_model_value}") - return body = get_invoke_model_body( llm_model_value, @@ -2246,7 +2241,6 @@ def test_invoke_model_no_content_tool_call( llm_model_config = AnthropicClaudeModel else: pytest.xfail("model family not handled: {model_family}") - return invoke_model_tool_call( span_exporter, @@ -2401,7 +2395,6 @@ def test_invoke_model_with_response_stream_with_content( } else: pytest.xfail("model family not handled: {model_family}") - return choice_body = { "index": 0, @@ -2437,7 +2430,6 @@ def test_invoke_model_with_response_stream_with_content_different_events( choice_content = [{"text": "This is a test", "type": "text"}] else: pytest.xfail("llm_model_value not handled: {llm_model_value}") - return max_tokens = 10 body = get_invoke_model_body( @@ -2672,7 +2664,6 @@ def test_invoke_model_with_response_stream_with_content_tool_call( llm_model_config = AnthropicClaudeModel else: pytest.xfail("model family not handled: {model_family}") - return invoke_model_with_response_stream_tool_call( span_exporter, @@ -2801,7 +2792,6 @@ def test_invoke_model_with_response_stream_no_content_different_events( finish_reason = "end_turn" else: pytest.xfail("llm_model_value not handled: {llm_model_value}") - return max_tokens = 10 body = get_invoke_model_body( @@ -2864,7 +2854,6 @@ def test_invoke_model_with_response_stream_no_content_tool_call( llm_model_config = AnthropicClaudeModel else: pytest.xfail("model family not handled: {model_family}") - return invoke_model_with_response_stream_tool_call( span_exporter, diff --git a/instrumentation/opentelemetry-instrumentation-threading/tests/test_threading.py b/instrumentation/opentelemetry-instrumentation-threading/tests/test_threading.py index 3a06969b26..e0f1c63fbb 100644 --- a/instrumentation/opentelemetry-instrumentation-threading/tests/test_threading.py +++ b/instrumentation/opentelemetry-instrumentation-threading/tests/test_threading.py @@ -15,7 +15,7 @@ from __future__ import annotations import threading -from concurrent.futures import ( # pylint: disable=no-name-in-module; TODO #4199 +from concurrent.futures import ( Future, ThreadPoolExecutor, ) diff --git a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py index 5c833a4720..0c92b6b6b8 100644 --- a/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-urllib3/src/opentelemetry/instrumentation/urllib3/__init__.py @@ -424,7 +424,7 @@ def _get_span_name(method: str) -> str: return method -# pylint: disable=too-many-locals +# pylint: disable=too-many-locals,too-many-positional-arguments def _instrument( tracer: Tracer, duration_histogram_old: Histogram, diff --git a/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py b/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py index 7e09e591e0..d28cc1e68d 100644 --- a/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py +++ b/processor/opentelemetry-processor-baggage/src/opentelemetry/processor/baggage/processor.py @@ -23,7 +23,7 @@ BaggageKeyPredicateT = Callable[[str], bool] # A BaggageKeyPredicate that always returns True, allowing all baggage keys to be added to spans -ALLOW_ALL_BAGGAGE_KEYS: BaggageKeyPredicateT = lambda _: True # noqa: E731 +ALLOW_ALL_BAGGAGE_KEYS: BaggageKeyPredicateT = lambda _: True # noqa: E731 # pylint:disable=invalid-name class BaggageSpanProcessor(SpanProcessor): diff --git a/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler/_sampling_rule.py b/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler/_sampling_rule.py index fd99b2a87f..0ee531017e 100644 --- a/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler/_sampling_rule.py +++ b/sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/trace/sampler/_sampling_rule.py @@ -20,7 +20,7 @@ # Disable snake_case naming style so this class can match the sampling rules response from X-Ray -# pylint: disable=invalid-name +# pylint: disable=invalid-name,too-many-positional-arguments class _SamplingRule: def __init__( self, diff --git a/util/opentelemetry-util-genai/src/opentelemetry/util/genai/_upload/completion_hook.py b/util/opentelemetry-util-genai/src/opentelemetry/util/genai/_upload/completion_hook.py index 79ebd3a170..f2b9254f49 100644 --- a/util/opentelemetry-util-genai/src/opentelemetry/util/genai/_upload/completion_hook.py +++ b/util/opentelemetry-util-genai/src/opentelemetry/util/genai/_upload/completion_hook.py @@ -22,7 +22,7 @@ import posixpath import threading from collections import OrderedDict -from concurrent.futures import ( # pylint: disable=no-name-in-module; TODO #4199 +from concurrent.futures import ( Future, ThreadPoolExecutor, )