From 50553313c4380cf21f7987b6c3592556a84de2f5 Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Tue, 15 Feb 2022 09:28:08 -0800 Subject: [PATCH 1/3] [build] bump pylint Fixes #632 --- dev-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev-requirements.txt b/dev-requirements.txt index fe54373e79..5b53cd381b 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,4 @@ -pylint<2.10 +pylint==2.12.2 flake8~=3.7 isort~=5.6 black>=22.1.0 From b5578c88d7bcf8dbdec59cb9a1d54b4aedd25053 Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Tue, 15 Feb 2022 09:51:46 -0800 Subject: [PATCH 2/3] apply lint suggestions --- .../tests/test_aiopg_integration.py | 5 ++++- .../tests/test_asgi_middleware.py | 16 ++++++++-------- .../tests/test_middleware_asgi.py | 7 +++---- .../tests/test_pymemcache.py | 4 ++-- .../src/opentelemetry/instrumentation/utils.py | 1 + 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/instrumentation/opentelemetry-instrumentation-aiopg/tests/test_aiopg_integration.py b/instrumentation/opentelemetry-instrumentation-aiopg/tests/test_aiopg_integration.py index 155c9948a8..3917d277f7 100644 --- a/instrumentation/opentelemetry-instrumentation-aiopg/tests/test_aiopg_integration.py +++ b/instrumentation/opentelemetry-instrumentation-aiopg/tests/test_aiopg_integration.py @@ -507,6 +507,7 @@ def __init__(self, database, server_port, server_host, user): self.server_host = server_host self.user = user + # pylint: disable=no-self-use async def release(self, conn): return conn @@ -542,11 +543,11 @@ def __init__(self, database, server_port, server_host, user): database, server_port, server_host, user ) - # pylint: disable=no-self-use def cursor(self): coro = self._cursor() return _ContextManager(coro) # pylint: disable=no-value-for-parameter + # pylint: disable=no-self-use async def _cursor(self): return MockCursor() @@ -585,6 +586,7 @@ async def __aenter__(self): class AiopgPoolMock: + # pylint: disable=no-self-use async def release(self, conn): return conn @@ -592,6 +594,7 @@ def acquire(self): coro = self._acquire() return _PoolAcquireContextManager(coro, self) + # pylint: disable=no-self-use async def _acquire(self): return AiopgConnectionMock() diff --git a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py index f1128b8cb3..4396dd224f 100644 --- a/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py +++ b/instrumentation/opentelemetry-instrumentation-asgi/tests/test_asgi_middleware.py @@ -310,10 +310,10 @@ def test_traceresponse_header(self): self.assertEqual(response_body["body"], b"*") self.assertEqual(response_start["status"], 200) - traceresponse = "00-{0}-{1}-01".format( - format_trace_id(span.get_span_context().trace_id), - format_span_id(span.get_span_context().span_id), - ) + trace_id = format_trace_id(span.get_span_context().trace_id) + span_id = format_span_id(span.get_span_context().span_id) + traceresponse = f"00-{trace_id}-{span_id}-01" + self.assertListEqual( response_start["headers"], [ @@ -423,10 +423,10 @@ def test_websocket_traceresponse_header(self): span = self.memory_exporter.get_finished_spans()[-1] self.assertEqual(trace_api.SpanKind.SERVER, span.kind) - traceresponse = "00-{0}-{1}-01".format( - format_trace_id(span.get_span_context().trace_id), - format_span_id(span.get_span_context().span_id), - ) + trace_id = format_trace_id(span.get_span_context().trace_id) + span_id = format_span_id(span.get_span_context().span_id) + traceresponse = f"00-{trace_id}-{span_id}-01" + self.assertListEqual( socket_send["headers"], [ diff --git a/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware_asgi.py b/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware_asgi.py index ecc3172e8b..baf1a92894 100644 --- a/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware_asgi.py +++ b/instrumentation/opentelemetry-instrumentation-django/tests/test_middleware_asgi.py @@ -368,12 +368,11 @@ async def test_trace_response_headers(self): response["Access-Control-Expose-Headers"], "traceresponse", ) + trace_id = format_trace_id(span.get_span_context().trace_id) + span_id = format_span_id(span.get_span_context().span_id) self.assertEqual( response["traceresponse"], - "00-{}-{}-01".format( - format_trace_id(span.get_span_context().trace_id), - format_span_id(span.get_span_context().span_id), - ), + f"00-{trace_id}-{span_id}-01", ) self.memory_exporter.clear() diff --git a/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py b/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py index bb9a225467..4756b5189d 100644 --- a/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py +++ b/instrumentation/opentelemetry-instrumentation-pymemcache/tests/test_pymemcache.py @@ -106,7 +106,7 @@ def test_set_not_recording(self): def test_get_many_none_found(self): client = self.make_client([b"END\r\n"]) result = client.get_many([b"key1", b"key2"]) - assert result == {} + assert not result spans = self.memory_exporter.get_finished_spans() @@ -116,7 +116,7 @@ def test_get_multi_none_found(self): client = self.make_client([b"END\r\n"]) # alias for get_many result = client.get_multi([b"key1", b"key2"]) - assert result == {} + assert not result spans = self.memory_exporter.get_finished_spans() diff --git a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py index b53b4f2308..ef21fccbf6 100644 --- a/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py +++ b/opentelemetry-instrumentation/src/opentelemetry/instrumentation/utils.py @@ -131,6 +131,7 @@ def _generate_sql_comment(**meta): # Sort the keywords to ensure that caching works and that testing is # deterministic. It eases visual inspection as well. + # pylint: disable=consider-using-f-string return ( " /*" + _KEY_VALUE_DELIMITER.join( From 055840dc48a0de3f3d1511718a06c653ca8dcff6 Mon Sep 17 00:00:00 2001 From: Alex Boten Date: Tue, 15 Feb 2022 10:16:44 -0800 Subject: [PATCH 3/3] specify encoding --- exporter/opentelemetry-exporter-richconsole/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/opentelemetry-exporter-richconsole/setup.py b/exporter/opentelemetry-exporter-richconsole/setup.py index 4237e6f2f0..db3c1ce7a6 100644 --- a/exporter/opentelemetry-exporter-richconsole/setup.py +++ b/exporter/opentelemetry-exporter-richconsole/setup.py @@ -21,7 +21,7 @@ BASE_DIR, "src", "opentelemetry", "exporter", "richconsole", "version.py" ) PACKAGE_INFO = {} -with open(VERSION_FILENAME) as f: +with open(VERSION_FILENAME, encoding="utf-8") as f: exec(f.read(), PACKAGE_INFO) setuptools.setup(version=PACKAGE_INFO["__version__"])