diff --git a/dev-requirements.txt b/dev-requirements.txt index 8ec964d1a81..613b5984c15 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,15 +1,15 @@ pylint==3.0.2 -flake8~=3.7 -isort~=5.8 -black~=22.3.0 -httpretty~=1.0 +flake8==6.1.0 +isort==5.12.0 +black==22.3.0 +httpretty==1.1.4 mypy==0.931 -sphinx~=7.1 +sphinx==7.1.2 sphinx-rtd-theme==2.0.0rc4 -sphinx-autodoc-typehints~=1.25 +sphinx-autodoc-typehints==1.25.2 pytest==7.1.3 -pytest-cov~=4.1 -readme-renderer~=24.0 +pytest-cov==4.1.0 +readme-renderer==42.0 # temporary fix. we should update the jinja, flask deps # See https://github.com/pallets/markupsafe/issues/282 # breaking change introduced in markupsafe causes jinja, flask to break @@ -18,3 +18,7 @@ bleach==4.1.0 # This dependency was updated to a breaking version. codespell==2.1.0 requests==2.31.0 ruamel.yaml==0.17.21 +asgiref==3.7.2 +psutil==5.9.6 +GitPython==3.1.40 +flaky==3.7.0 diff --git a/exporter/opentelemetry-exporter-otlp-proto-common/pyproject.toml b/exporter/opentelemetry-exporter-otlp-proto-common/pyproject.toml index 4751da63a47..bef34ed82bb 100644 --- a/exporter/opentelemetry-exporter-otlp-proto-common/pyproject.toml +++ b/exporter/opentelemetry-exporter-otlp-proto-common/pyproject.toml @@ -30,6 +30,9 @@ dependencies = [ "backoff >= 1.10.0, < 3.0.0; python_version>='3.7'", ] +[project.optional-dependencies] +test = [] + [project.urls] Homepage = "https://github.com/open-telemetry/opentelemetry-python/tree/main/exporter/opentelemetry-exporter-otlp-proto-common" diff --git a/exporter/opentelemetry-exporter-otlp/pyproject.toml b/exporter/opentelemetry-exporter-otlp/pyproject.toml index cfd8843cab4..707b8c94556 100644 --- a/exporter/opentelemetry-exporter-otlp/pyproject.toml +++ b/exporter/opentelemetry-exporter-otlp/pyproject.toml @@ -30,6 +30,9 @@ dependencies = [ "opentelemetry-exporter-otlp-proto-http == 1.22.0.dev", ] +[project.optional-dependencies] +test = [] + [project.entry-points.opentelemetry_logs_exporter] otlp = "opentelemetry.exporter.otlp.proto.grpc._log_exporter:OTLPLogExporter" diff --git a/opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py b/opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py index ac57b5c919e..7fefd8dea67 100644 --- a/opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py +++ b/opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py @@ -39,7 +39,7 @@ def test_no_traceparent_header(self): If no traceparent header is received, the vendor creates a new trace-id and parent-id that represents the current request. """ - output = {} # type:typing.Dict[str, typing.List[str]] + output: typing.Dict[str, typing.List[str]] = {} span = trace.get_current_span(FORMAT.extract(output)) self.assertIsInstance(span.get_span_context(), trace.SpanContext) @@ -66,7 +66,7 @@ def test_headers_with_tracestate(self): span_context.trace_state, {"foo": "1", "bar": "2", "baz": "3"} ) self.assertTrue(span_context.is_remote) - output = {} # type:typing.Dict[str, str] + output: typing.Dict[str, str] = {} span = trace.NonRecordingSpan(span_context) ctx = trace.set_span_in_context(span) @@ -145,7 +145,7 @@ def test_no_send_empty_tracestate(self): Empty and whitespace-only list members are allowed. Vendors MUST accept empty tracestate headers but SHOULD avoid sending them. """ - output = {} # type:typing.Dict[str, str] + output: typing.Dict[str, str] = {} span = trace.NonRecordingSpan( trace.SpanContext(self.TRACE_ID, self.SPAN_ID, is_remote=False) ) @@ -177,7 +177,7 @@ def test_format_not_supported(self): def test_propagate_invalid_context(self): """Do not propagate invalid trace context.""" - output = {} # type:typing.Dict[str, str] + output: typing.Dict[str, str] = {} ctx = trace.set_span_in_context(trace.INVALID_SPAN) FORMAT.inject(output, context=ctx) self.assertFalse("traceparent" in output) diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py index 8ccad56c7a1..14140d26b73 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/export/__init__.py @@ -166,6 +166,10 @@ class BatchLogRecordProcessor(LogRecordProcessor): - :envvar:`OTEL_BLRP_EXPORT_TIMEOUT` """ + _queue: Deque[LogData] + _flush_request: Optional[_FlushRequest] + _log_records: List[Optional[LogData]] + def __init__( self, exporter: LogExporter, @@ -201,9 +205,7 @@ def __init__( self._schedule_delay_millis = schedule_delay_millis self._max_export_batch_size = max_export_batch_size self._export_timeout_millis = export_timeout_millis - self._queue = collections.deque( - [], max_queue_size - ) # type: Deque[LogData] + self._queue = collections.deque([], max_queue_size) self._worker_thread = threading.Thread( name="OtelBatchLogRecordProcessor", target=self.worker, @@ -211,10 +213,8 @@ def __init__( ) self._condition = threading.Condition(threading.Lock()) self._shutdown = False - self._flush_request = None # type: Optional[_FlushRequest] - self._log_records = [ - None - ] * self._max_export_batch_size # type: List[Optional[LogData]] + self._flush_request = None + self._log_records = [None] * self._max_export_batch_size self._worker_thread.start() # Only available in *nix since py37. if hasattr(os, "register_at_fork"): @@ -236,7 +236,7 @@ def _at_fork_reinit(self): def worker(self): timeout = self._schedule_delay_millis / 1e3 - flush_request = None # type: Optional[_FlushRequest] + flush_request: Optional[_FlushRequest] = None while not self._shutdown: with self._condition: if self._shutdown: diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py index 8897585607a..6dae70b2f6b 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/trace/__init__.py @@ -140,10 +140,12 @@ class SynchronousMultiSpanProcessor(SpanProcessor): added. """ + _span_processors: Tuple[SpanProcessor, ...] + def __init__(self): # use a tuple to avoid race conditions when adding a new span and # iterating through it on "on_start" and "on_end". - self._span_processors = () # type: Tuple[SpanProcessor, ...] + self._span_processors = () self._lock = threading.Lock() def add_span_processor(self, span_processor: SpanProcessor) -> None: diff --git a/tests/opentelemetry-test-utils/src/opentelemetry/test/test_base.py b/tests/opentelemetry-test-utils/src/opentelemetry/test/test_base.py index f7451f0d3c6..15d6bb60669 100644 --- a/tests/opentelemetry-test-utils/src/opentelemetry/test/test_base.py +++ b/tests/opentelemetry-test-utils/src/opentelemetry/test/test_base.py @@ -180,7 +180,9 @@ def is_data_points_equal( data_point: DataPointT, est_value_delta: Optional[float] = 0, ): - if type(expected_data_point) != type(data_point) or not isinstance( + if type(expected_data_point) != type( # noqa: E721 + data_point + ) or not isinstance( expected_data_point, (HistogramDataPoint, NumberDataPoint) ): return False diff --git a/tox.ini b/tox.ini index 9e441d08326..e3f0866f523 100644 --- a/tox.ini +++ b/tox.ini @@ -204,10 +204,6 @@ basepython: python3 recreate = True deps = -r dev-requirements.txt - asgiref~=3.7 - psutil~=5.9 - GitPython==3.1.40 - flaky~=3.7 commands_pre = python -m pip install -e {toxinidir}/opentelemetry-api[test]