Repository: open-telemetry/opentelemetry-python

Issue:
Upgrade mypy to 0.800
MyPy 0.800 is out. It finally supports namespace packages properly and we can remove the placeholder `__init__.pyi` files in a few spots.


Discussion:
I will take this issue
Thanks @dmolenda-sumo 

Resolving patch:
diff --git a/opentelemetry-api/src/opentelemetry/context/__init__.py b/opentelemetry-api/src/opentelemetry/context/__init__.py
--- 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
--- 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)
 
 


Test patch:
diff --git a/opentelemetry-api/tests/baggage/test_baggage.py b/opentelemetry-api/tests/baggage/test_baggage.py
--- 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
--- 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
--- 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
--- 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
--- 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
--- 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
--- 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