From 145a37a756052bca461ba66e54f18648299ae3d1 Mon Sep 17 00:00:00 2001 From: Matthew-Selvam Date: Mon, 5 Oct 2026 09:49:40 +0530 Subject: [PATCH] Add return type annotations to MultiLogRecordProcessor classes SynchronousMultiLogRecordProcessor.__init__, ConcurrentMultiLogRecordProcessor.__init__, and ConcurrentMultiLogRecordProcessor.add_log_record_processor were missing return type annotations. The Concurrent add_log_record_processor already had the annotation on its Synchronous sibling, so the pair was inconsistent. SynchronousMultiLogRecordProcessor.__init__ has no annotated parameters either, so mypy --strict reports no-untyped-call for downstream callers constructing it in typed contexts. This follows #5709 and #5718, which annotated InMemoryLogRecordExporter and ConsoleLogRecordExporter in the same package. Assisted-by: Hermes Agent (stealth/space-bunny-alpha) --- .changelog/5742.fixed | 1 + .../src/opentelemetry/sdk/_logs/_internal/__init__.py | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 .changelog/5742.fixed diff --git a/.changelog/5742.fixed b/.changelog/5742.fixed new file mode 100644 index 00000000000..a11d1072ab4 --- /dev/null +++ b/.changelog/5742.fixed @@ -0,0 +1 @@ +`opentelemetry-sdk`: add return type annotations to `SynchronousMultiLogRecordProcessor` and `ConcurrentMultiLogRecordProcessor` diff --git a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py index bc09fd1db0f..5b543d01e44 100644 --- a/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py +++ b/opentelemetry-sdk/src/opentelemetry/sdk/_logs/_internal/__init__.py @@ -412,7 +412,7 @@ class SynchronousMultiLogRecordProcessor(LogRecordProcessor): added. """ - def __init__(self): + def __init__(self) -> None: # use a tuple to avoid race conditions when adding a new log and # iterating through it on "emit". self._log_record_processors = () # type: tuple[LogRecordProcessor, ...] @@ -489,14 +489,14 @@ class ConcurrentMultiLogRecordProcessor(LogRecordProcessor): and thus defining how many log processors can work in parallel. """ - def __init__(self, max_workers: int = 2): + def __init__(self, max_workers: int = 2) -> None: # use a tuple to avoid race conditions when adding a new log and # iterating through it on "emit". self._log_record_processors = () # type: tuple[LogRecordProcessor, ...] self._lock = threading.Lock() self._executor = concurrent.futures.ThreadPoolExecutor(max_workers=max_workers) - def add_log_record_processor(self, log_record_processor: LogRecordProcessor): + def add_log_record_processor(self, log_record_processor: LogRecordProcessor) -> None: with self._lock: self._log_record_processors += (log_record_processor,)