From eba9a2a65d01a1c8ef5d3ea75b9299060fc01319 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Thu, 10 Mar 2022 15:06:59 +0000 Subject: [PATCH] work around old typeshed stubs for importlib.metadata --- distributed/comm/registry.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/distributed/comm/registry.py b/distributed/comm/registry.py index 15d9af51781..47ba730a7d9 100644 --- a/distributed/comm/registry.py +++ b/distributed/comm/registry.py @@ -4,9 +4,18 @@ import sys from abc import ABC, abstractmethod from collections.abc import Iterable +from typing import Protocol + + +class _EntryPoints(Protocol): + def __call__(self, **kwargs: str) -> Iterable[importlib.metadata.EntryPoint]: + ... + if sys.version_info >= (3, 10): - _entry_points = importlib.metadata.entry_points + # py3.10 importlib.metadata type annotations are not in mypy yet + # https://github.com/python/typeshed/pull/7331 + _entry_points: _EntryPoints = importlib.metadata.entry_points # type: ignore[assignment] else: def _entry_points(