From 0e9f8ac641c9761f9dc7a239b96e16d928063896 Mon Sep 17 00:00:00 2001 From: Luke Zhang Date: Mon, 13 Oct 2025 20:16:30 -0700 Subject: [PATCH 1/2] fix: suppress ruff PLC0415 for conditional gevent import The generate_instrumentation_bootstrap.py script was failing with a ruff linting error (PLC0415: import should be at top-level) when checking the auto_instrumentation module. Add noqa comment to suppress this error for the gevent monkey patch import, which is intentionally inside a try-except block for conditional loading. This allows the bootstrap generation script to complete successfully. --- .../instrumentation/auto_instrumentation/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py index 1c87d2c327..caac0a5776 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/auto_instrumentation/__init__.py @@ -149,7 +149,7 @@ def initialize(*, swallow_exceptions: bool = True) -> None: else: try: # pylint: disable=import-outside-toplevel - from gevent import monkey + from gevent import monkey # noqa: PLC0415 getattr(monkey, gevent_patch)() except ImportError: From a67aebd01b15b57ec94bba40dae0508982e94c88 Mon Sep 17 00:00:00 2001 From: Luke Zhang Date: Mon, 10 Nov 2025 16:02:49 -0800 Subject: [PATCH 2/2] Bump ruff to 0.14.1 and fix new lint warnings. --- .../src/generate_workflows_lib/__init__.py | 2 +- .pre-commit-config.yaml | 2 +- CHANGELOG.md | 4 +- dev-requirements.txt | 2 +- .../test_prometheus_remote_write_exporter.py | 6 +-- gen-requirements.txt | 2 +- .../tests/common/otel_mocker.py | 12 ++--- .../instrumentation/openai_v2/__init__.py | 2 +- .../instrumentation/vertexai/__init__.py | 6 +-- .../tests/test_function_calling.py | 8 +-- .../test_function_calling_experimental.py | 8 +-- .../tests/test_asyncclick.py | 6 +-- .../tests/bedrock_utils.py | 6 +-- .../tests/test_fastapi_instrumentation.py | 12 ++--- .../tests/test_programmatic.py | 4 +- .../instrumentation/grpc/__init__.py | 8 +-- .../instrumentation/grpc/grpcext/__init__.py | 2 +- .../tests/test_pika_instrumentation.py | 12 ++--- .../tests/test_pymemcache.py | 2 +- .../tests/test_sqlalchemy.py | 54 ++++++++++++------- .../tests/test_sqlcommenter.py | 12 +++-- .../util/genai/_upload/__init__.py | 2 +- .../tests/test_upload.py | 2 +- 23 files changed, 99 insertions(+), 77 deletions(-) diff --git a/.github/workflows/generate_workflows_lib/src/generate_workflows_lib/__init__.py b/.github/workflows/generate_workflows_lib/src/generate_workflows_lib/__init__.py index b01211ebbc..d57aa108d3 100644 --- a/.github/workflows/generate_workflows_lib/src/generate_workflows_lib/__init__.py +++ b/.github/workflows/generate_workflows_lib/src/generate_workflows_lib/__init__.py @@ -143,7 +143,7 @@ def get_contrib_job_datas(tox_envs: list) -> list: contrib_job_datas.append( { - "ui_name": (f"{groups['name']}" f"{contrib_requirements}"), + "ui_name": (f"{groups['name']}{contrib_requirements}"), "tox_env": tox_env, } ) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5b9bf9973f..01486fbda9 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,7 +1,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit # Ruff version. - rev: v0.6.9 + rev: v0.14.1 hooks: # Run the linter. - id: ruff diff --git a/CHANGELOG.md b/CHANGELOG.md index b36b689b60..34eaeb0136 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,7 +43,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `opentelemetry-instrumentation-aiohttp-server`: delay initialization of tracer, meter and excluded urls to instrumentation for testability ([#3836](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3836)) - `opentelemetry-instrumentation-elasticsearch`: Enhance elasticsearch query body sanitization - ([#3919](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3919)) + ([#3919](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3919)) +- build: bump ruff to 0.14.1 + ([#3842](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/3842)) ## Version 1.38.0/0.59b0 (2025-10-16) diff --git a/dev-requirements.txt b/dev-requirements.txt index b41f3d7b99..b2de8cecfc 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -15,4 +15,4 @@ ruamel.yaml==0.17.21 flaky==3.7.0 pre-commit==3.7.0; python_version >= '3.9' pre-commit==3.5.0; python_version < '3.9' -ruff==0.6.9 +ruff==0.14.1 diff --git a/exporter/opentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py b/exporter/opentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py index 1c50344353..814de75be4 100644 --- a/exporter/opentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py +++ b/exporter/opentelemetry-exporter-prometheus-remote-write/tests/test_prometheus_remote_write_exporter.py @@ -122,9 +122,9 @@ def test_parse_metric(metric, prom_rw): "bool_value": True, } - assert ( - len(metric.data.data_points) == 1 - ), "We can only support a single datapoint in tests" + assert len(metric.data.data_points) == 1, ( + "We can only support a single datapoint in tests" + ) series = prom_rw._parse_metric(metric, tuple(attributes.items())) timestamp = metric.data.data_points[0].time_unix_nano // 1_000_000 for single_series in series: diff --git a/gen-requirements.txt b/gen-requirements.txt index 57bfcd89a0..2512362a93 100644 --- a/gen-requirements.txt +++ b/gen-requirements.txt @@ -2,7 +2,7 @@ astor==0.8.1 jinja2==3.1.6 markupsafe==2.0.1 -ruff==0.6.9 +ruff==0.14.1 requests tomli tomli_w diff --git a/instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/common/otel_mocker.py b/instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/common/otel_mocker.py index d3ef52a9c5..1d1fa26194 100644 --- a/instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/common/otel_mocker.py +++ b/instrumentation-genai/opentelemetry-instrumentation-google-genai/tests/common/otel_mocker.py @@ -164,9 +164,9 @@ def get_span_named(self, name): def assert_has_span_named(self, name): span = self.get_span_named(name) finished_spans = [span.name for span in self.get_finished_spans()] - assert ( - span is not None - ), f'Could not find span named "{name}"; finished spans: {finished_spans}' + assert span is not None, ( + f'Could not find span named "{name}"; finished spans: {finished_spans}' + ) def assert_does_not_have_span_named(self, name): span = self.get_span_named(name) @@ -192,9 +192,9 @@ def get_events_named(self, event_name): def assert_has_event_named(self, name): event = self.get_event_named(name) finished_logs = self.get_finished_logs() - assert ( - event is not None - ), f'Could not find event named "{name}"; finished logs: {finished_logs}' + assert event is not None, ( + f'Could not find event named "{name}"; finished logs: {finished_logs}' + ) def assert_does_not_have_event_named(self, name): event = self.get_event_named(name) diff --git a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/__init__.py b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/__init__.py index f822265259..9e4a24855e 100644 --- a/instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/__init__.py +++ b/instrumentation-genai/opentelemetry-instrumentation-openai-v2/src/opentelemetry/instrumentation/openai_v2/__init__.py @@ -129,7 +129,7 @@ def _instrument(self, **kwargs): ) def _uninstrument(self, **kwargs): - import openai # pylint: disable=import-outside-toplevel + import openai # pylint: disable=import-outside-toplevel # noqa: PLC0415 unwrap(openai.resources.chat.completions.Completions, "create") unwrap(openai.resources.chat.completions.AsyncCompletions, "create") diff --git a/instrumentation-genai/opentelemetry-instrumentation-vertexai/src/opentelemetry/instrumentation/vertexai/__init__.py b/instrumentation-genai/opentelemetry-instrumentation-vertexai/src/opentelemetry/instrumentation/vertexai/__init__.py index 960e35ae46..24d9d46af4 100644 --- a/instrumentation-genai/opentelemetry-instrumentation-vertexai/src/opentelemetry/instrumentation/vertexai/__init__.py +++ b/instrumentation-genai/opentelemetry-instrumentation-vertexai/src/opentelemetry/instrumentation/vertexai/__init__.py @@ -68,14 +68,14 @@ def _methods_to_wrap( ): # This import is very slow, do it lazily in case instrument() is not called # pylint: disable=import-outside-toplevel - from google.cloud.aiplatform_v1.services.prediction_service import ( + from google.cloud.aiplatform_v1.services.prediction_service import ( # noqa: PLC0415 async_client, client, ) - from google.cloud.aiplatform_v1beta1.services.prediction_service import ( + from google.cloud.aiplatform_v1beta1.services.prediction_service import ( # noqa: PLC0415 async_client as async_client_v1beta1, ) - from google.cloud.aiplatform_v1beta1.services.prediction_service import ( + from google.cloud.aiplatform_v1beta1.services.prediction_service import ( # noqa: PLC0415 client as client_v1beta1, ) diff --git a/instrumentation-genai/opentelemetry-instrumentation-vertexai/tests/test_function_calling.py b/instrumentation-genai/opentelemetry-instrumentation-vertexai/tests/test_function_calling.py index 88762d6100..4ff06aa379 100644 --- a/instrumentation-genai/opentelemetry-instrumentation-vertexai/tests/test_function_calling.py +++ b/instrumentation-genai/opentelemetry-instrumentation-vertexai/tests/test_function_calling.py @@ -1,4 +1,8 @@ import pytest +from tests.shared_test_utils import ( + ask_about_weather, + ask_about_weather_function_response, +) from opentelemetry.instrumentation.vertexai import VertexAIInstrumentor from opentelemetry.sdk._logs._internal.export.in_memory_log_exporter import ( @@ -7,10 +11,6 @@ from opentelemetry.sdk.trace.export.in_memory_span_exporter import ( InMemorySpanExporter, ) -from tests.shared_test_utils import ( - ask_about_weather, - ask_about_weather_function_response, -) @pytest.mark.vcr() diff --git a/instrumentation-genai/opentelemetry-instrumentation-vertexai/tests/test_function_calling_experimental.py b/instrumentation-genai/opentelemetry-instrumentation-vertexai/tests/test_function_calling_experimental.py index 9cfc0222a3..76d3fd31e6 100644 --- a/instrumentation-genai/opentelemetry-instrumentation-vertexai/tests/test_function_calling_experimental.py +++ b/instrumentation-genai/opentelemetry-instrumentation-vertexai/tests/test_function_calling_experimental.py @@ -4,6 +4,10 @@ import fsspec import pytest +from tests.shared_test_utils import ( + ask_about_weather, + ask_about_weather_function_response, +) from opentelemetry.instrumentation.vertexai import VertexAIInstrumentor from opentelemetry.sdk._logs._internal.export.in_memory_log_exporter import ( @@ -12,10 +16,6 @@ from opentelemetry.sdk.trace.export.in_memory_span_exporter import ( InMemorySpanExporter, ) -from tests.shared_test_utils import ( - ask_about_weather, - ask_about_weather_function_response, -) def test_function_call_choice( diff --git a/instrumentation/opentelemetry-instrumentation-asyncclick/tests/test_asyncclick.py b/instrumentation/opentelemetry-instrumentation-asyncclick/tests/test_asyncclick.py index d7104d5059..989752f686 100644 --- a/instrumentation/opentelemetry-instrumentation-asyncclick/tests/test_asyncclick.py +++ b/instrumentation/opentelemetry-instrumentation-asyncclick/tests/test_asyncclick.py @@ -351,9 +351,9 @@ async def command1() -> None: async def command2() -> None: pass - async def run_both() -> ( - tuple[asyncclick.testing.Result, asyncclick.testing.Result] - ): + async def run_both() -> tuple[ + asyncclick.testing.Result, asyncclick.testing.Result + ]: runner = CliRunner() task1 = asyncio.create_task(runner.invoke(command1)) task2 = asyncio.create_task(runner.invoke(command2)) diff --git a/instrumentation/opentelemetry-instrumentation-botocore/tests/bedrock_utils.py b/instrumentation/opentelemetry-instrumentation-botocore/tests/bedrock_utils.py index 4f46137074..cd357f9597 100644 --- a/instrumentation/opentelemetry-instrumentation-botocore/tests/bedrock_utils.py +++ b/instrumentation/opentelemetry-instrumentation-botocore/tests/bedrock_utils.py @@ -279,9 +279,9 @@ def remove_none_values(body): def assert_log_parent(log, span): if span: - assert ( - log.log_record.trace_id == span.get_span_context().trace_id - ), f"{span.get_span_context().trace_id} does not equal {log.log_record.trace_id}" + assert log.log_record.trace_id == span.get_span_context().trace_id, ( + f"{span.get_span_context().trace_id} does not equal {log.log_record.trace_id}" + ) assert log.log_record.span_id == span.get_span_context().span_id assert ( log.log_record.trace_flags == span.get_span_context().trace_flags diff --git a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py index 661c7097cd..d60b169fec 100644 --- a/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-fastapi/tests/test_fastapi_instrumentation.py @@ -287,9 +287,9 @@ def test_fastapi_unhandled_exception(self): """If the application has an unhandled error the instrumentation should capture that a 500 response is returned.""" try: resp = self._client.get("/error") - assert ( - resp.status_code == 500 - ), resp.content # pragma: no cover, for debugging this test if an exception is _not_ raised + assert resp.status_code == 500, ( + resp.content + ) # pragma: no cover, for debugging this test if an exception is _not_ raised except UnhandledException: pass else: @@ -2442,9 +2442,9 @@ def test_fastapi_unhandled_exception_both_semconv(self): """If the application has an unhandled error the instrumentation should capture that a 500 response is returned.""" try: resp = self._client.get("/error") - assert ( - resp.status_code == 500 - ), resp.content # pragma: no cover, for debugging this test if an exception is _not_ raised + assert resp.status_code == 500, ( + resp.content + ) # pragma: no cover, for debugging this test if an exception is _not_ raised except UnhandledException: pass else: diff --git a/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py b/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py index 2da579adda..cfd45cf6df 100644 --- a/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py +++ b/instrumentation/opentelemetry-instrumentation-flask/tests/test_programmatic.py @@ -879,7 +879,7 @@ def response_hook_test(span, environ, response_headers): request_hook=request_hook_test, response_hook=response_hook_test ) # pylint: disable=import-outside-toplevel,reimported,redefined-outer-name - from flask import Flask + from flask import Flask # noqa: PLC0415 self.app = Flask(__name__) @@ -949,7 +949,7 @@ def setUp(self): FlaskInstrumentor().instrument(tracer_provider=tracer_provider) # pylint: disable=import-outside-toplevel,reimported,redefined-outer-name - from flask import Flask + from flask import Flask # noqa: PLC0415 self.app = Flask(__name__) diff --git a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py index 37610d0628..ee838a87ef 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/__init__.py @@ -584,7 +584,7 @@ def client_interceptor( Returns: An invocation-side interceptor object. """ - from . import _client + from . import _client # noqa: PLC0415 tracer = trace.get_tracer( __name__, @@ -614,7 +614,7 @@ def server_interceptor(tracer_provider=None, filter_=None): Returns: A service-side interceptor object. """ - from . import _server + from . import _server # noqa: PLC0415 tracer = trace.get_tracer( __name__, @@ -637,7 +637,7 @@ def aio_client_interceptors( Returns: An invocation-side interceptor object. """ - from . import _aio_client + from . import _aio_client # noqa: PLC0415 tracer = trace.get_tracer( __name__, @@ -683,7 +683,7 @@ def aio_server_interceptor(tracer_provider=None, filter_=None): Returns: A service-side interceptor object. """ - from . import _aio_server + from . import _aio_server # noqa: PLC0415 tracer = trace.get_tracer( __name__, diff --git a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/grpcext/__init__.py b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/grpcext/__init__.py index d5e2549bab..298778f892 100644 --- a/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/grpcext/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-grpc/src/opentelemetry/instrumentation/grpc/grpcext/__init__.py @@ -112,7 +112,7 @@ def intercept_channel(channel, *interceptors): TypeError: If an interceptor derives from neither UnaryClientInterceptor nor StreamClientInterceptor. """ - from . import _interceptor + from . import _interceptor # noqa: PLC0415 return _interceptor.intercept_channel(channel, *interceptors) diff --git a/instrumentation/opentelemetry-instrumentation-pika/tests/test_pika_instrumentation.py b/instrumentation/opentelemetry-instrumentation-pika/tests/test_pika_instrumentation.py index 2733140ffa..f2a82a4d3f 100644 --- a/instrumentation/opentelemetry-instrumentation-pika/tests/test_pika_instrumentation.py +++ b/instrumentation/opentelemetry-instrumentation-pika/tests/test_pika_instrumentation.py @@ -59,9 +59,9 @@ def test_instrument_api(self) -> None: _QueueConsumerGeneratorInfo.__init__, BoundFunctionWrapper ) ) - assert hasattr( - instrumentation, "__opentelemetry_tracer_provider" - ), "Tracer not stored for the object!" + assert hasattr(instrumentation, "__opentelemetry_tracer_provider"), ( + "Tracer not stored for the object!" + ) instrumentation.uninstrument() self.assertFalse( isinstance(BlockingConnection.channel, BoundFunctionWrapper) @@ -115,9 +115,9 @@ def test_instrument_channel( instrument_channel_functions: mock.MagicMock, ): PikaInstrumentor.instrument_channel(channel=self.channel) - assert hasattr( - self.channel, "_is_instrumented_by_opentelemetry" - ), "channel is not marked as instrumented!" + assert hasattr(self.channel, "_is_instrumented_by_opentelemetry"), ( + "channel is not marked as instrumented!" + ) instrument_channel_consumers.assert_called_once() instrument_basic_consume.assert_called_once() instrument_channel_functions.assert_called_once() diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py b/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py index f888009017..b9ad948819 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py @@ -552,7 +552,7 @@ def make_client(self, *mock_socket_values, **kwargs): current_port = TEST_PORT # pylint: disable=import-outside-toplevel - from pymemcache.client.hash import HashClient + from pymemcache.client.hash import HashClient # noqa: PLC0415 # pylint: disable=attribute-defined-outside-init self.client = HashClient([], **kwargs) diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy.py b/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy.py index 770a3e945d..136f737ce1 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy.py +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlalchemy.py @@ -111,7 +111,7 @@ def test_instrument_engine_connect(self): ) def test_async_trace_integration(self): async def run(): - from sqlalchemy.ext.asyncio import ( # pylint: disable-all + from sqlalchemy.ext.asyncio import ( # pylint: disable-all # noqa: PLC0415 create_async_engine, ) @@ -161,7 +161,9 @@ def test_not_recording(self): def test_create_engine_wrapper(self): SQLAlchemyInstrumentor().instrument() - from sqlalchemy import create_engine # pylint: disable-all + from sqlalchemy import ( # noqa: PLC0415 + create_engine, # pylint: disable-all + ) engine = create_engine("sqlite:///:memory:") cnx = engine.connect() @@ -188,7 +190,9 @@ def test_create_engine_wrapper(self): def test_instrument_engine_from_config(self): SQLAlchemyInstrumentor().instrument() - from sqlalchemy import engine_from_config # pylint: disable-all + from sqlalchemy import ( # noqa: PLC0415 + engine_from_config, # pylint: disable-all + ) engine = engine_from_config({"sqlalchemy.url": "sqlite:///:memory:"}) cnx = engine.connect() @@ -203,7 +207,9 @@ def test_create_engine_wrapper_enable_commenter(self): enable_commenter=True, commenter_options={"db_framework": False}, ) - from sqlalchemy import create_engine # pylint: disable-all + from sqlalchemy import ( # noqa: PLC0415 + create_engine, # pylint: disable-all + ) engine = create_engine("sqlite:///:memory:") cnx = engine.connect() @@ -231,7 +237,9 @@ def test_create_engine_wrapper_enable_commenter_stmt_enabled(self): commenter_options={"db_framework": False}, enable_attribute_commenter=True, ) - from sqlalchemy import create_engine # pylint: disable-all + from sqlalchemy import ( # noqa: PLC0415 + create_engine, # pylint: disable-all + ) engine = create_engine("sqlite:///:memory:") cnx = engine.connect() @@ -261,7 +269,9 @@ def test_create_engine_wrapper_enable_commenter_otel_values_false(self): "opentelemetry_values": False, }, ) - from sqlalchemy import create_engine # pylint: disable-all + from sqlalchemy import ( # noqa: PLC0415 + create_engine, # pylint: disable-all + ) engine = create_engine("sqlite:///:memory:") cnx = engine.connect() @@ -294,7 +304,9 @@ def test_create_engine_wrapper_enable_commenter_stmt_enabled_otel_values_false( }, enable_attribute_commenter=True, ) - from sqlalchemy import create_engine # pylint: disable-all + from sqlalchemy import ( # noqa: PLC0415 + create_engine, # pylint: disable-all + ) engine = create_engine("sqlite:///:memory:") cnx = engine.connect() @@ -330,7 +342,9 @@ def test_custom_tracer_provider(self): ) SQLAlchemyInstrumentor().instrument(tracer_provider=provider) - from sqlalchemy import create_engine # pylint: disable-all + from sqlalchemy import ( # noqa: PLC0415 + create_engine, # pylint: disable-all + ) engine = create_engine("sqlite:///:memory:") cnx = engine.connect() @@ -353,7 +367,7 @@ def test_custom_tracer_provider(self): def test_create_async_engine_wrapper(self): async def run(): SQLAlchemyInstrumentor().instrument() - from sqlalchemy.ext.asyncio import ( # pylint: disable-all + from sqlalchemy.ext.asyncio import ( # pylint: disable-all # noqa: PLC0415 create_async_engine, ) @@ -394,7 +408,7 @@ async def run(): "db_framework": False, }, ) - from sqlalchemy.ext.asyncio import ( # pylint: disable-all + from sqlalchemy.ext.asyncio import ( # pylint: disable-all # noqa: PLC0415 create_async_engine, ) @@ -433,7 +447,7 @@ async def run(): }, enable_attribute_commenter=True, ) - from sqlalchemy.ext.asyncio import ( # pylint: disable-all + from sqlalchemy.ext.asyncio import ( # pylint: disable-all # noqa: PLC0415 create_async_engine, ) @@ -474,7 +488,7 @@ async def run(): "opentelemetry_values": False, }, ) - from sqlalchemy.ext.asyncio import ( # pylint: disable-all + from sqlalchemy.ext.asyncio import ( # pylint: disable-all # noqa: PLC0415 create_async_engine, ) @@ -516,7 +530,7 @@ async def run(): }, enable_attribute_commenter=True, ) - from sqlalchemy.ext.asyncio import ( # pylint: disable-all + from sqlalchemy.ext.asyncio import ( # pylint: disable-all # noqa: PLC0415 create_async_engine, ) @@ -581,7 +595,7 @@ def test_uninstrument_without_engine(self): SQLAlchemyInstrumentor().instrument( tracer_provider=self.tracer_provider ) - from sqlalchemy import create_engine + from sqlalchemy import create_engine # noqa: PLC0415 engine = create_engine("sqlite:///:memory:") @@ -609,12 +623,12 @@ def test_no_op_tracer_provider(self): def test_no_memory_leakage_if_engine_diposed(self): SQLAlchemyInstrumentor().instrument() - import gc - import weakref + import gc # noqa: PLC0415 + import weakref # noqa: PLC0415 - from sqlalchemy import create_engine + from sqlalchemy import create_engine # noqa: PLC0415 - from opentelemetry.instrumentation.sqlalchemy.engine import ( + from opentelemetry.instrumentation.sqlalchemy.engine import ( # noqa: PLC0415 EngineTracer, ) @@ -638,7 +652,7 @@ def make_shortlived_engine(): def test_suppress_instrumentation_create_engine(self): SQLAlchemyInstrumentor().instrument() - from sqlalchemy import create_engine + from sqlalchemy import create_engine # noqa: PLC0415 with suppress_instrumentation(): engine = create_engine("sqlite:///:memory:") @@ -652,7 +666,7 @@ def test_suppress_instrumentation_create_engine(self): def test_suppress_instrumentation_create_async_engine(self): async def run(): SQLAlchemyInstrumentor().instrument() - from sqlalchemy.ext.asyncio import ( # pylint: disable-all + from sqlalchemy.ext.asyncio import ( # pylint: disable-all # noqa: PLC0415 create_async_engine, ) diff --git a/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlcommenter.py b/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlcommenter.py index d8144dadc1..b81eede1b2 100644 --- a/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlcommenter.py +++ b/instrumentation/opentelemetry-instrumentation-sqlalchemy/tests/test_sqlcommenter.py @@ -304,7 +304,9 @@ def test_sqlcommenter_enabled_create_engine_after_instrumentation(self): tracer_provider=self.tracer_provider, enable_commenter=True, ) - from sqlalchemy import create_engine # pylint: disable-all + from sqlalchemy import ( # noqa: PLC0415 + create_engine, # pylint: disable-all + ) engine = create_engine("sqlite:///:memory:") cnx = engine.connect() @@ -332,7 +334,9 @@ def test_sqlcommenter_enabled_stmt_enabled_create_engine_after_instrumentation( enable_commenter=True, enable_attribute_commenter=True, ) - from sqlalchemy import create_engine # pylint: disable-all + from sqlalchemy import ( # noqa: PLC0415 + create_engine, # pylint: disable-all + ) engine = create_engine("sqlite:///:memory:") cnx = engine.connect() @@ -357,7 +361,9 @@ def test_sqlcommenter_disabled_create_engine_after_instrumentation(self): tracer_provider=self.tracer_provider, enable_commenter=False, ) - from sqlalchemy import create_engine # pylint: disable-all + from sqlalchemy import ( # noqa: PLC0415 + create_engine, # pylint: disable-all + ) engine = create_engine("sqlite:///:memory:") cnx = engine.connect() diff --git a/util/opentelemetry-util-genai/src/opentelemetry/util/genai/_upload/__init__.py b/util/opentelemetry-util-genai/src/opentelemetry/util/genai/_upload/__init__.py index 92316192b2..a9e2515cf4 100644 --- a/util/opentelemetry-util-genai/src/opentelemetry/util/genai/_upload/__init__.py +++ b/util/opentelemetry-util-genai/src/opentelemetry/util/genai/_upload/__init__.py @@ -29,7 +29,7 @@ def upload_completion_hook() -> CompletionHook: # If fsspec is not installed the hook will be a no-op. try: # pylint: disable=import-outside-toplevel - from opentelemetry.util.genai._upload.completion_hook import ( + from opentelemetry.util.genai._upload.completion_hook import ( # noqa: PLC0415 UploadCompletionHook, ) except ImportError: diff --git a/util/opentelemetry-util-genai/tests/test_upload.py b/util/opentelemetry-util-genai/tests/test_upload.py index baa0696d1b..7c24bcfc97 100644 --- a/util/opentelemetry-util-genai/tests/test_upload.py +++ b/util/opentelemetry-util-genai/tests/test_upload.py @@ -58,7 +58,7 @@ def test_upload_entry_point(self): def test_upload_entry_point_no_fsspec(self): """Tests that the a no-op uploader is used when fsspec is not installed""" - from opentelemetry.util.genai import _upload + from opentelemetry.util.genai import _upload # noqa: PLC0415 # Simulate fsspec imports failing with patch.dict(