Skip to content

Commit

Permalink
Avoid TypeAlias at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Tinche committed Oct 13, 2024
1 parent 98630d0 commit 58246be
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
3 changes: 1 addition & 2 deletions src/attr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from . import converters, exceptions, filters, setters, validators
from ._cmp import cmp_using
from ._compat import TypeAlias
from ._config import get_run_validators, set_run_validators
from ._funcs import asdict, assoc, astuple, evolve, has, resolve_types
from ._make import (
Expand Down Expand Up @@ -38,7 +37,7 @@ class AttrsInstance(Protocol):
pass


NothingType: TypeAlias = Literal[_Nothing.NOTHING]
NothingType = Literal[_Nothing.NOTHING]

__all__ = [
"Attribute",
Expand Down
5 changes: 2 additions & 3 deletions src/attr/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ from typing import (
Mapping,
Protocol,
Sequence,
TypeAlias,
TypeVar,
overload,
)
Expand Down Expand Up @@ -39,9 +38,9 @@ from attrs import (
)

if sys.version_info >= (3, 10):
from typing import TypeGuard
from typing import TypeGuard, TypeAlias
else:
from typing_extensions import TypeGuard
from typing_extensions import TypeGuard, TypeAlias

if sys.version_info >= (3, 11):
from typing import dataclass_transform
Expand Down
4 changes: 0 additions & 4 deletions src/attr/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
PY_3_13_PLUS = sys.version_info[:2] >= (3, 13)
PY_3_14_PLUS = sys.version_info[:2] >= (3, 14)

try:
from typing import TypeAlias
except ImportError:
from typing_extensions import TypeAlias # noqa: F401

if PY_3_14_PLUS: # pragma: no cover
import annotationlib
Expand Down

0 comments on commit 58246be

Please sign in to comment.