Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make more use of typing_extensions module #2460

Merged
merged 2 commits into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 6 additions & 24 deletions plugin/core/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,16 @@
cast,
final,
)
from typing_extensions import ( # noqa: F401
NotRequired,
ParamSpec,
Required,
TypeGuard,
)

if sys.version_info >= (3, 11):
from enum import StrEnum # noqa: F401
from typing import ( # noqa: F401
NotRequired,
ParamSpec,
Required,
TypeGuard,
)
else:
_T = TypeVar("_T")

class StrEnum(str, Enum):
"""
Naive polyfill for Python 3.11's StrEnum.
Expand All @@ -48,19 +46,3 @@ class StrEnum(str, Enum):

__format__ = str.__format__
__str__ = str.__str__

class NotRequired(Type, Generic[_T]): # type: ignore
pass

class ParamSpec(Type): # type: ignore
args = ...
kwargs = ...

def __init__(*args, **kwargs) -> None: # type: ignore
pass

class Required(Type, Generic[_T]): # type: ignore
pass

class TypeGuard(Type, Generic[_T]): # type: ignore
pass