diff --git a/baseplate/lib/propagator_redditb3.py b/baseplate/lib/propagator_redditb3.py index 8e0ab6a1c..372b433f1 100644 --- a/baseplate/lib/propagator_redditb3.py +++ b/baseplate/lib/propagator_redditb3.py @@ -1,10 +1,11 @@ import logging + +from re import compile as re_compile from typing import Any from typing import Iterable from typing import Optional from typing import Set - -from re import compile as re_compile +from typing import Union from opentelemetry import trace from opentelemetry.context import Context @@ -40,9 +41,9 @@ def extract( ) -> Context: if context is None: context = Context() - trace_id: Optional[int] = trace.INVALID_TRACE_ID - span_id: Optional[int] = trace.INVALID_SPAN_ID - sampled: Optional[int] = "0" + trace_id: Union[int, str] = trace.INVALID_TRACE_ID + span_id: Union[int, str] = trace.INVALID_SPAN_ID + sampled: Union[int, str] = "0" flags: Optional[Iterable[str]] = None trace_id = _extract_first_element(getter.get(carrier, self.TRACE_ID_KEY), default=trace_id) @@ -154,8 +155,8 @@ def fields(self) -> Set[str]: def _extract_first_element( - items: Iterable[CarrierT], - default: Optional[Any] = None, + items: Optional[Iterable[CarrierT]], + default: Any, ) -> Optional[CarrierT]: if items is None: return default