Skip to content

Commit a3867f4

Browse files
authored
Make more use of typing_extensions module (#2460)
* Make more use of typing_extensions module This commit replaces various homegrown type definitions by imports from typing_extensions module. * Simplify typing_extensions imports The `typing_extensions` module is a compatibility layer between python versions. Required types can always be imported from it, even if available via `typing` natively.
1 parent 4c8da78 commit a3867f4

File tree

1 file changed

+6
-24
lines changed

1 file changed

+6
-24
lines changed

plugin/core/typing.py

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,16 @@
2727
cast,
2828
final,
2929
)
30+
from typing_extensions import ( # noqa: F401
31+
NotRequired,
32+
ParamSpec,
33+
Required,
34+
TypeGuard,
35+
)
3036

3137
if sys.version_info >= (3, 11):
3238
from enum import StrEnum # noqa: F401
33-
from typing import ( # noqa: F401
34-
NotRequired,
35-
ParamSpec,
36-
Required,
37-
TypeGuard,
38-
)
3939
else:
40-
_T = TypeVar("_T")
41-
4240
class StrEnum(str, Enum):
4341
"""
4442
Naive polyfill for Python 3.11's StrEnum.
@@ -48,19 +46,3 @@ class StrEnum(str, Enum):
4846

4947
__format__ = str.__format__
5048
__str__ = str.__str__
51-
52-
class NotRequired(Type, Generic[_T]): # type: ignore
53-
pass
54-
55-
class ParamSpec(Type): # type: ignore
56-
args = ...
57-
kwargs = ...
58-
59-
def __init__(*args, **kwargs) -> None: # type: ignore
60-
pass
61-
62-
class Required(Type, Generic[_T]): # type: ignore
63-
pass
64-
65-
class TypeGuard(Type, Generic[_T]): # type: ignore
66-
pass

0 commit comments

Comments
 (0)