Skip to content

Commit

Permalink
Simplify typing_extensions imports
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
deathaxe committed Apr 21, 2024
1 parent 3b41c63 commit a2ef215
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions plugin/core/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +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:
from typing_extensions import ( # noqa: F401
NotRequired,
ParamSpec,
Required,
TypeGuard,
)

class StrEnum(str, Enum):
"""
Naive polyfill for Python 3.11's StrEnum.
Expand Down

0 comments on commit a2ef215

Please sign in to comment.