From e864f36492f62cc5e48ccdb42d1a3dc2214d3ea2 Mon Sep 17 00:00:00 2001 From: Ashutosh Goel Date: Thu, 17 Feb 2022 15:43:24 +0530 Subject: [PATCH] Formatting changes for fixing lint errors --- .../src/opentelemetry/util/http/__init__.py | 12 +++++--- .../tests/test_capture_custom_headers.py | 30 +++++++++++-------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/util/opentelemetry-util-http/src/opentelemetry/util/http/__init__.py b/util/opentelemetry-util-http/src/opentelemetry/util/http/__init__.py index 3fd1d93e11..a7c8ebd2e8 100644 --- a/util/opentelemetry-util-http/src/opentelemetry/util/http/__init__.py +++ b/util/opentelemetry-util-http/src/opentelemetry/util/http/__init__.py @@ -19,8 +19,8 @@ from urllib.parse import urlparse, urlunparse -OTEL_PYTHON_CAPTURE_REQUEST_HEADERS = 'OTEL_PYTHON_CAPTURE_REQUEST_HEADERS' -OTEL_PYTHON_CAPTURE_RESPONSE_HEADERS = 'OTEL_PYTHON_CAPTURE_RESPONSE_HEADERS' +OTEL_PYTHON_CAPTURE_REQUEST_HEADERS = "OTEL_PYTHON_CAPTURE_REQUEST_HEADERS" +OTEL_PYTHON_CAPTURE_RESPONSE_HEADERS = "OTEL_PYTHON_CAPTURE_RESPONSE_HEADERS" class ExcludeList: @@ -105,11 +105,15 @@ def remove_url_credentials(url: str) -> str: def normalise_request_header_name(header): - return 'http.request.header.{key}'.format(key=header.lower().replace('-', '_')) + return "http.request.header.{key}".format( + key=header.lower().replace("-", "_") + ) def normalise_response_header_name(header): - return 'http.response.header.{key}'.format(key=header.lower().replace('-', '_')) + return "http.response.header.{key}".format( + key=header.lower().replace("-", "_") + ) def get_custom_headers(env_var): diff --git a/util/opentelemetry-util-http/tests/test_capture_custom_headers.py b/util/opentelemetry-util-http/tests/test_capture_custom_headers.py index 1b937b4190..596d94cd9a 100644 --- a/util/opentelemetry-util-http/tests/test_capture_custom_headers.py +++ b/util/opentelemetry-util-http/tests/test_capture_custom_headers.py @@ -20,20 +20,20 @@ normalise_request_header_name, normalise_response_header_name, OTEL_PYTHON_CAPTURE_REQUEST_HEADERS, - OTEL_PYTHON_CAPTURE_RESPONSE_HEADERS + OTEL_PYTHON_CAPTURE_RESPONSE_HEADERS, ) class TestCaptureCustomHeaders(TestBase): @patch.dict( "os.environ", - { - OTEL_PYTHON_CAPTURE_REQUEST_HEADERS: "User-Agent,Test-Header" - }, + {OTEL_PYTHON_CAPTURE_REQUEST_HEADERS: "User-Agent,Test-Header"}, ) def test_get_custom_request_header(self): - custom_headers_to_capture = get_custom_headers(OTEL_PYTHON_CAPTURE_REQUEST_HEADERS) - assert custom_headers_to_capture == ['User-Agent', 'Test-Header'] + custom_headers_to_capture = get_custom_headers( + OTEL_PYTHON_CAPTURE_REQUEST_HEADERS + ) + assert custom_headers_to_capture == ["User-Agent", "Test-Header"] @patch.dict( "os.environ", @@ -42,13 +42,19 @@ def test_get_custom_request_header(self): }, ) def test_get_custom_response_header(self): - custom_headers_to_capture = get_custom_headers(OTEL_PYTHON_CAPTURE_RESPONSE_HEADERS) - assert custom_headers_to_capture == ['content-type', 'content-length', 'test-header'] + custom_headers_to_capture = get_custom_headers( + OTEL_PYTHON_CAPTURE_RESPONSE_HEADERS + ) + assert custom_headers_to_capture == [ + "content-type", + "content-length", + "test-header", + ] def test_normalise_request_header_name(self): - key = normalise_request_header_name('Test-Header') - assert key == 'http.request.header.test_header' + key = normalise_request_header_name("Test-Header") + assert key == "http.request.header.test_header" def test_normalise_response_header_name(self): - key = normalise_response_header_name('Test-Header') - assert key == 'http.response.header.test_header' + key = normalise_response_header_name("Test-Header") + assert key == "http.response.header.test_header"