diff --git a/dev-requirements.txt b/dev-requirements.txt index bd2515b1170..87dc7adc59f 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -3,7 +3,7 @@ flake8~=3.7 isort~=5.6 black>=19.3b0,==19.* httpretty~=1.0 -mypy==0.790 +mypy==0.812 sphinx~=2.1 sphinx-rtd-theme~=0.4 sphinx-autodoc-typehints~=1.10.2 diff --git a/opentelemetry-api/src/opentelemetry/__init__.pyi b/opentelemetry-api/src/opentelemetry/__init__.pyi deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/opentelemetry-api/src/opentelemetry/context/__init__.py b/opentelemetry-api/src/opentelemetry/context/__init__.py index 3328d627720..0f60d86a0c7 100644 --- a/opentelemetry-api/src/opentelemetry/context/__init__.py +++ b/opentelemetry-api/src/opentelemetry/context/__init__.py @@ -37,8 +37,8 @@ def _load_runtime_context(func: _F) -> _F: A wrapper of the decorated method. """ - @wraps(func) # type: ignore - def wrapper( + @wraps(func) # type: ignore[misc] + def wrapper( # type: ignore[misc] *args: typing.Tuple[typing.Any, typing.Any], **kwargs: typing.Dict[typing.Any, typing.Any] ) -> typing.Optional[typing.Any]: @@ -63,9 +63,9 @@ def wrapper( logger.error( "Failed to load context: %s", configured_context ) - return func(*args, **kwargs) # type: ignore + return func(*args, **kwargs) # type: ignore[misc] - return wrapper # type:ignore + return typing.cast(_F, wrapper) # type: ignore[misc] def get_value(key: str, context: typing.Optional[Context] = None) -> "object": diff --git a/opentelemetry-api/src/opentelemetry/util/_time.py b/opentelemetry-api/src/opentelemetry/util/_time.py index 10a2aee33e6..aa61bc02aa4 100644 --- a/opentelemetry-api/src/opentelemetry/util/_time.py +++ b/opentelemetry-api/src/opentelemetry/util/_time.py @@ -25,7 +25,7 @@ ) from time import time - def _time_ns(): + def _time_ns() -> int: return int(time() * 1e9) diff --git a/opentelemetry-api/tests/baggage/test_baggage.py b/opentelemetry-api/tests/baggage/test_baggage.py index 276d2bc8b0a..62f3fb77d5d 100644 --- a/opentelemetry-api/tests/baggage/test_baggage.py +++ b/opentelemetry-api/tests/baggage/test_baggage.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# type: ignore + import unittest from opentelemetry import baggage, context diff --git a/opentelemetry-api/tests/baggage/test_baggage_propagation.py b/opentelemetry-api/tests/baggage/test_baggage_propagation.py index a928a2fc8cb..3047ddbbe46 100644 --- a/opentelemetry-api/tests/baggage/test_baggage_propagation.py +++ b/opentelemetry-api/tests/baggage/test_baggage_propagation.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# type: ignore + import unittest from unittest.mock import Mock, patch diff --git a/opentelemetry-api/tests/propagators/test_composite.py b/opentelemetry-api/tests/propagators/test_composite.py index 232e177d3d0..e33649bbdd8 100644 --- a/opentelemetry-api/tests/propagators/test_composite.py +++ b/opentelemetry-api/tests/propagators/test_composite.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# type: ignore + import unittest from unittest.mock import Mock diff --git a/opentelemetry-api/tests/propagators/test_global_httptextformat.py b/opentelemetry-api/tests/propagators/test_global_httptextformat.py index faa4023d5da..6ba32e46183 100644 --- a/opentelemetry-api/tests/propagators/test_global_httptextformat.py +++ b/opentelemetry-api/tests/propagators/test_global_httptextformat.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# type: ignore + import unittest from opentelemetry import baggage, trace diff --git a/opentelemetry-api/tests/propagators/test_propagators.py b/opentelemetry-api/tests/propagators/test_propagators.py index 1ea80146ef8..80299d34904 100644 --- a/opentelemetry-api/tests/propagators/test_propagators.py +++ b/opentelemetry-api/tests/propagators/test_propagators.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# type: ignore + from importlib import reload from os import environ from unittest import TestCase diff --git a/opentelemetry-api/tests/trace/propagation/test_textmap.py b/opentelemetry-api/tests/trace/propagation/test_textmap.py index 12e851de348..e47a0d22cb4 100644 --- a/opentelemetry-api/tests/trace/propagation/test_textmap.py +++ b/opentelemetry-api/tests/trace/propagation/test_textmap.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# type: ignore + import unittest from opentelemetry.propagators.textmap import DictGetter diff --git a/opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py b/opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py index cff30b7c9b8..79683d43d94 100644 --- a/opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py +++ b/opentelemetry-api/tests/trace/propagation/test_tracecontexthttptextformat.py @@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +# type: ignore + import typing import unittest from unittest.mock import Mock, patch diff --git a/tox.ini b/tox.ini index 4865be24276..c07bbd9e7f6 100644 --- a/tox.ini +++ b/tox.ini @@ -149,7 +149,7 @@ commands = test: pytest {posargs} coverage: {toxinidir}/scripts/coverage.sh - mypy: mypy --namespace-packages opentelemetry-api/src/opentelemetry/ + mypy: mypy --namespace-packages --explicit-package-bases opentelemetry-api/src/opentelemetry/ ; For test code, we don't want to enforce the full mypy strictness mypy: mypy --namespace-packages --config-file=mypy-relaxed.ini opentelemetry-api/tests/