Skip to content

Commit 2bb013f

Browse files
authored
Merge branch 'main' into issue-2443
2 parents f4686ff + 6bb3ece commit 2bb013f

File tree

7 files changed

+23
-20
lines changed

7 files changed

+23
-20
lines changed

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ flake8~=3.7
33
isort~=5.8
44
black~=22.1.0
55
httpretty~=1.0
6-
mypy==0.812
6+
mypy==0.931
77
sphinx~=3.5.4
88
sphinx-rtd-theme~=0.5
99
sphinx-autodoc-typehints~=1.12.0

opentelemetry-api/src/opentelemetry/baggage/propagation/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#
1515
from logging import getLogger
1616
from re import split
17-
from typing import Iterable, Mapping, Optional, Set
17+
from typing import Iterable, List, Mapping, Optional, Set
1818
from urllib.parse import quote_plus, unquote_plus
1919

2020
from opentelemetry.baggage import _is_valid_pair, get_all, set_baggage
@@ -63,7 +63,7 @@ def extract(
6363
)
6464
return context
6565

66-
baggage_entries = split(_DELIMITER_PATTERN, header)
66+
baggage_entries: List[str] = split(_DELIMITER_PATTERN, header)
6767
total_baggage_entries = self._MAX_PAIRS
6868

6969
if len(baggage_entries) > self._MAX_PAIRS:

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def start_span(
326326
The newly-created span.
327327
"""
328328

329-
@contextmanager # type: ignore
329+
@contextmanager
330330
@abstractmethod
331331
def start_as_current_span(
332332
self,
@@ -449,7 +449,7 @@ def start_span(
449449
# pylint: disable=unused-argument,no-self-use
450450
return INVALID_SPAN
451451

452-
@contextmanager # type: ignore
452+
@contextmanager
453453
def start_as_current_span(
454454
self,
455455
name: str,
@@ -535,7 +535,7 @@ def get_tracer_provider() -> TracerProvider:
535535
return cast("TracerProvider", _TRACER_PROVIDER)
536536

537537

538-
@contextmanager # type: ignore
538+
@contextmanager
539539
def use_span(
540540
span: Span,
541541
end_on_exit: bool = False,

opentelemetry-api/src/opentelemetry/trace/propagation/tracecontext.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ def extract(
5555
if not match:
5656
return context
5757

58-
version = match.group(1)
59-
trace_id = match.group(2)
60-
span_id = match.group(3)
61-
trace_flags = match.group(4)
58+
version: str = match.group(1)
59+
trace_id: str = match.group(2)
60+
span_id: str = match.group(3)
61+
trace_flags: str = match.group(4)
6262

6363
if trace_id == "0" * 32 or span_id == "0" * 16:
6464
return context
6565

6666
if version == "00":
67-
if match.group(5):
67+
if match.group(5): # type: ignore
6868
return context
6969
if version == "ff":
7070
return context

opentelemetry-api/src/opentelemetry/trace/span.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,9 +352,10 @@ def from_header(cls, header_list: typing.List[str]) -> "TraceState":
352352
If the number of keys is beyond the maximum, all values
353353
will be discarded and an empty tracestate will be returned.
354354
"""
355-
pairs = OrderedDict()
355+
pairs = OrderedDict() # type: OrderedDict[str, str]
356356
for header in header_list:
357-
for member in re.split(_delimiter_pattern, header):
357+
members: typing.List[str] = re.split(_delimiter_pattern, header)
358+
for member in members:
358359
# empty members are valid, but no need to process further.
359360
if not member:
360361
continue
@@ -365,7 +366,8 @@ def from_header(cls, header_list: typing.List[str]) -> "TraceState":
365366
member,
366367
)
367368
return cls()
368-
key, _eq, value = match.groups()
369+
groups: typing.Tuple[str, ...] = match.groups()
370+
key, _eq, value = groups
369371
# duplicate keys are not legal in header
370372
if key in pairs:
371373
return cls()

opentelemetry-api/src/opentelemetry/util/re.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import logging
1616
from re import compile, split
17-
from typing import Mapping
17+
from typing import Dict, List, Mapping
1818
from urllib.parse import unquote
1919

2020
_logger = logging.getLogger(__name__)
@@ -42,8 +42,9 @@ def parse_headers(s: str) -> Mapping[str, str]:
4242
HTTP header format https://www.w3.org/TR/baggage/#baggage-http-header-format, except that
4343
additional semi-colon delimited metadata is not supported.
4444
"""
45-
headers = {}
46-
for header in split(_DELIMITER_PATTERN, s):
45+
headers: Dict[str, str] = {}
46+
headers_list: List[str] = split(_DELIMITER_PATTERN, s)
47+
for header in headers_list:
4748
if not header: # empty string
4849
continue
4950
match = _HEADER_PATTERN.fullmatch(header.strip())

tox.ini

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,13 @@ commands =
165165
opentelemetry: pytest {posargs}
166166
coverage: {toxinidir}/scripts/coverage.sh
167167

168-
mypy: mypy --namespace-packages --explicit-package-bases opentelemetry-api/src/opentelemetry/
168+
mypy: mypy --install-types --non-interactive --namespace-packages --explicit-package-bases opentelemetry-api/src/opentelemetry/
169169
; For test code, we don't want to enforce the full mypy strictness
170-
mypy: mypy --namespace-packages --config-file=mypy-relaxed.ini opentelemetry-api/tests/
170+
mypy: mypy --install-types --non-interactive --namespace-packages --config-file=mypy-relaxed.ini opentelemetry-api/tests/
171171

172172
; Test that mypy can pick up typeinfo from an installed package (otherwise,
173173
; implicit Any due to unfollowed import would result).
174-
mypyinstalled: mypy --namespace-packages opentelemetry-api/tests/mypysmoke.py --strict
174+
mypyinstalled: mypy --install-types --non-interactive --namespace-packages opentelemetry-api/tests/mypysmoke.py --strict
175175

176176
[testenv:lint]
177177
basepython: python3.9

0 commit comments

Comments
 (0)