From 10f3c7c3bda6a56b193f2f8c15e53188d1f19609 Mon Sep 17 00:00:00 2001 From: Neema Date: Tue, 22 Oct 2024 07:08:47 +0530 Subject: [PATCH 1/4] Adding rule A --- docs/conf.py | 2 +- opentelemetry-api/src/opentelemetry/baggage/__init__.py | 4 ++-- package-lock.json | 6 ++++++ pyproject.toml | 1 + .../src/opentelemetry/shim/opentracing_shim/__init__.py | 8 ++++---- 5 files changed, 14 insertions(+), 7 deletions(-) create mode 100644 package-lock.json diff --git a/docs/conf.py b/docs/conf.py index 965a806d06a..77936accb6c 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -47,7 +47,7 @@ # -- Project information ----------------------------------------------------- project = "OpenTelemetry Python" -copyright = "OpenTelemetry Authors" # pylint: disable=redefined-builtin +docs_copyright = "OpenTelemetry Authors" # pylint: disable=redefined-builtin author = "OpenTelemetry Authors" diff --git a/opentelemetry-api/src/opentelemetry/baggage/__init__.py b/opentelemetry-api/src/opentelemetry/baggage/__init__.py index 9a740200a6f..1948543653e 100644 --- a/opentelemetry-api/src/opentelemetry/baggage/__init__.py +++ b/opentelemetry-api/src/opentelemetry/baggage/__init__.py @@ -121,8 +121,8 @@ def _is_valid_value(value: object) -> bool: parts = str(value).split(";") is_valid_value = _VALUE_PATTERN.fullmatch(parts[0]) is not None if len(parts) > 1: # one or more properties metadata - for property in parts[1:]: - if _PROPERT_PATTERN.fullmatch(property) is None: + for properties in parts[1:]: + if _PROPERT_PATTERN.fullmatch(properties) is None: is_valid_value = False break return is_valid_value diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000000..89b4c6e1ed8 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "opentelemetry-python", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/pyproject.toml b/pyproject.toml index ab84e2d398d..a342a73401e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -31,6 +31,7 @@ select = [ "PLC", # pylint convention "PLE", # pylint error "Q", # flake8-quotes + "A", # flake8-builtins ] ignore = [ diff --git a/shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/__init__.py b/shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/__init__.py index a06d7834722..847ebae3e11 100644 --- a/shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/__init__.py +++ b/shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/__init__.py @@ -684,7 +684,7 @@ def start_span( context = SpanContextShim(span.get_span_context()) return SpanShim(self, context, span) - def inject(self, span_context, format: object, carrier: object): + def inject(self, span_context, formats: object, carrier: object): """Injects ``span_context`` into ``carrier``. See base class for more details. @@ -703,7 +703,7 @@ def inject(self, span_context, format: object, carrier: object): # TODO: Support Format.BINARY once it is supported in # opentelemetry-python. - if format not in self._supported_formats: + if formats not in self._supported_formats: raise UnsupportedFormatException propagator = get_global_textmap() @@ -715,7 +715,7 @@ def inject(self, span_context, format: object, carrier: object): ctx = set_span_in_context(span) propagator.inject(carrier, context=ctx) - def extract(self, format: object, carrier: object): + def extract(self, formats: object, carrier: object): """Returns an ``opentracing.SpanContext`` instance extracted from a ``carrier``. @@ -737,7 +737,7 @@ def extract(self, format: object, carrier: object): # uses the configured propagators in opentelemetry.propagators. # TODO: Support Format.BINARY once it is supported in # opentelemetry-python. - if format not in self._supported_formats: + if formats not in self._supported_formats: raise UnsupportedFormatException propagator = get_global_textmap() From 3ca67cf7eceba7913ad505202f8c21d74de9f48e Mon Sep 17 00:00:00 2001 From: Neema Date: Tue, 22 Oct 2024 19:57:45 +0530 Subject: [PATCH 2/4] reverted changes made rule A --- docs/conf.py | 2 +- opentelemetry-api/src/opentelemetry/baggage/__init__.py | 4 ++-- package-lock.json | 6 ------ .../src/opentelemetry/shim/opentracing_shim/__init__.py | 8 ++++---- 4 files changed, 7 insertions(+), 13 deletions(-) delete mode 100644 package-lock.json diff --git a/docs/conf.py b/docs/conf.py index 77936accb6c..965a806d06a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -47,7 +47,7 @@ # -- Project information ----------------------------------------------------- project = "OpenTelemetry Python" -docs_copyright = "OpenTelemetry Authors" # pylint: disable=redefined-builtin +copyright = "OpenTelemetry Authors" # pylint: disable=redefined-builtin author = "OpenTelemetry Authors" diff --git a/opentelemetry-api/src/opentelemetry/baggage/__init__.py b/opentelemetry-api/src/opentelemetry/baggage/__init__.py index 1948543653e..9a740200a6f 100644 --- a/opentelemetry-api/src/opentelemetry/baggage/__init__.py +++ b/opentelemetry-api/src/opentelemetry/baggage/__init__.py @@ -121,8 +121,8 @@ def _is_valid_value(value: object) -> bool: parts = str(value).split(";") is_valid_value = _VALUE_PATTERN.fullmatch(parts[0]) is not None if len(parts) > 1: # one or more properties metadata - for properties in parts[1:]: - if _PROPERT_PATTERN.fullmatch(properties) is None: + for property in parts[1:]: + if _PROPERT_PATTERN.fullmatch(property) is None: is_valid_value = False break return is_valid_value diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 89b4c6e1ed8..00000000000 --- a/package-lock.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "opentelemetry-python", - "lockfileVersion": 3, - "requires": true, - "packages": {} -} diff --git a/shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/__init__.py b/shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/__init__.py index 847ebae3e11..a06d7834722 100644 --- a/shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/__init__.py +++ b/shim/opentelemetry-opentracing-shim/src/opentelemetry/shim/opentracing_shim/__init__.py @@ -684,7 +684,7 @@ def start_span( context = SpanContextShim(span.get_span_context()) return SpanShim(self, context, span) - def inject(self, span_context, formats: object, carrier: object): + def inject(self, span_context, format: object, carrier: object): """Injects ``span_context`` into ``carrier``. See base class for more details. @@ -703,7 +703,7 @@ def inject(self, span_context, formats: object, carrier: object): # TODO: Support Format.BINARY once it is supported in # opentelemetry-python. - if formats not in self._supported_formats: + if format not in self._supported_formats: raise UnsupportedFormatException propagator = get_global_textmap() @@ -715,7 +715,7 @@ def inject(self, span_context, formats: object, carrier: object): ctx = set_span_in_context(span) propagator.inject(carrier, context=ctx) - def extract(self, formats: object, carrier: object): + def extract(self, format: object, carrier: object): """Returns an ``opentracing.SpanContext`` instance extracted from a ``carrier``. @@ -737,7 +737,7 @@ def extract(self, formats: object, carrier: object): # uses the configured propagators in opentelemetry.propagators. # TODO: Support Format.BINARY once it is supported in # opentelemetry-python. - if formats not in self._supported_formats: + if format not in self._supported_formats: raise UnsupportedFormatException propagator = get_global_textmap() From efe0966b32ab09ab293b0f5f5da96fc8f3c0c81e Mon Sep 17 00:00:00 2001 From: Neema Date: Tue, 22 Oct 2024 21:28:47 +0530 Subject: [PATCH 3/4] Adding ruff rule N --- pyproject.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index a342a73401e..24a64025367 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,8 @@ select = [ "PLE", # pylint error "Q", # flake8-quotes "A", # flake8-builtins + "B", # flake8-bugbear + "N", # pep8-naming ] ignore = [ From bde198968d566c6e5bc1b6aa676f227d3a6a6df8 Mon Sep 17 00:00:00 2001 From: Neema Date: Tue, 22 Oct 2024 21:33:29 +0530 Subject: [PATCH 4/4] Adding ruff rule RUF --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 24a64025367..502f6039992 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -34,6 +34,7 @@ select = [ "A", # flake8-builtins "B", # flake8-bugbear "N", # pep8-naming + "RUF", # Ruff-specific rules ] ignore = [