Skip to content

Commit

Permalink
Fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Feb 24, 2023
1 parent 055cd62 commit f8ac076
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion opentelemetry-api/src/opentelemetry/context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# pylint: disable=wrong-import-position
from opentelemetry.context.context import Context, _RuntimeContext # noqa
from opentelemetry.environment_variables import OTEL_PYTHON_CONTEXT
from opentelemetry.util._importlib_metadata import entry_points
from opentelemetry.util._importlib_metadata import entry_points # type: ignore

logger = logging.getLogger(__name__)
_RUNTIME_CONTEXT = None # type: typing.Optional[_RuntimeContext]
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/src/opentelemetry/propagate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def example_route():
from opentelemetry.context.context import Context
from opentelemetry.environment_variables import OTEL_PROPAGATORS
from opentelemetry.propagators import composite, textmap
from opentelemetry.util._importlib_metadata import entry_points
from opentelemetry.util._importlib_metadata import entry_points # type: ignore

logger = getLogger(__name__)

Expand Down
18 changes: 13 additions & 5 deletions opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# type: ignore

from sys import version_info
from typing import Dict, List, Union
from typing import Dict, Tuple, Union

# This is a cache to avoid going through creating a dictionary for all entry
# points for 3.7 every time the entry points function is called.
Expand All @@ -24,11 +26,13 @@
# pylint: disable=import-error
from importlib_metadata import EntryPoint
from importlib_metadata import (
entry_points as importlib_metadata_entry_points, # type: ignore
entry_points as importlib_metadata_entry_points,
)
from importlib_metadata import version

def entry_points(group: str = None, name: str = None) -> Union[List, Dict]:
def entry_points(
group: str = None, name: str = None
) -> Union[Tuple, Dict]:

if group is None and name is None:

Expand Down Expand Up @@ -84,7 +88,9 @@ def entry_points(group: str = None, name: str = None) -> Union[List, Dict]:
)
from importlib.metadata import version

def entry_points(group: str = None, name: str = None) -> Union[List, Dict]:
def entry_points(
group: str = None, name: str = None
) -> Union[Tuple, Dict]:

result_key_entry_points = importlib_metadata_entry_points()

Expand Down Expand Up @@ -130,7 +136,9 @@ def entry_points(group: str = None, name: str = None) -> Union[List, Dict]:
)
from importlib.metadata import version

def entry_points(group: str = None, name: str = None) -> Union[List, Dict]:
def entry_points(
group: str = None, name: str = None
) -> Union[Tuple, Dict]:

if group is None and name is None:
result_entry_points = {}
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-api/src/opentelemetry/util/_providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from os import environ
from typing import TYPE_CHECKING, TypeVar, cast

from opentelemetry.util._importlib_metadata import entry_points
from opentelemetry.util._importlib_metadata import entry_points # type: ignore

if TYPE_CHECKING:
from opentelemetry.metrics import MeterProvider
Expand Down
2 changes: 2 additions & 0 deletions opentelemetry-api/tests/util/test__importlib_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# type: ignore

from typing import Dict, Tuple
from unittest import TestCase

Expand Down

0 comments on commit f8ac076

Please sign in to comment.