Skip to content

Commit dc8b76e

Browse files
committed
add correct typing to propagator
1 parent 4b2c1b6 commit dc8b76e

File tree

1 file changed

+9
-7
lines changed
  • opentelemetry-api/src/opentelemetry/propagate

1 file changed

+9
-7
lines changed

opentelemetry-api/src/opentelemetry/propagate/__init__.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def example_route():
7070

7171
from logging import getLogger
7272
from os import environ
73-
from typing import Optional
73+
from typing import List, Optional
7474

7575
from opentelemetry.context.context import Context
7676
from opentelemetry.environment_variables import OTEL_PROPAGATORS
@@ -121,7 +121,7 @@ def inject(
121121
get_global_textmap().inject(carrier, context=context, setter=setter)
122122

123123

124-
propagators = [] # type: ignore
124+
propagators: List[textmap.TextMapPropagator] = []
125125

126126
# Single use variable here to hack black and make lint pass
127127
environ_propagators = environ.get(
@@ -136,13 +136,13 @@ def inject(
136136
logger.debug(
137137
"OTEL_PROPAGATORS environment variable contains none, removing all propagators"
138138
)
139-
propagators = []
139+
propagators = []
140140
break
141141
try:
142-
propagators.append( # type: ignore
142+
propagators.append(
143143
next( # type: ignore
144144
iter( # type: ignore
145-
entry_points( # type: ignore
145+
entry_points( # type: ignore[misc]
146146
group="opentelemetry_propagator",
147147
name=propagator,
148148
)
@@ -158,7 +158,9 @@ def inject(
158158
raise
159159

160160

161-
_HTTP_TEXT_FORMAT = composite.CompositePropagator(propagators) # type: ignore
161+
_HTTP_TEXT_FORMAT: textmap.TextMapPropagator = composite.CompositePropagator(
162+
propagators
163+
)
162164

163165

164166
def get_global_textmap() -> textmap.TextMapPropagator:
@@ -169,4 +171,4 @@ def set_global_textmap(
169171
http_text_format: textmap.TextMapPropagator,
170172
) -> None:
171173
global _HTTP_TEXT_FORMAT # pylint:disable=global-statement
172-
_HTTP_TEXT_FORMAT = http_text_format # type: ignore
174+
_HTTP_TEXT_FORMAT = http_text_format

0 commit comments

Comments
 (0)