Skip to content

Commit

Permalink
Fixed typing_extensions being imported unconditionally on Python < 3.9
Browse files Browse the repository at this point in the history
Fixes #217.
  • Loading branch information
agronholm committed Nov 22, 2021
1 parent 2516f18 commit 4615f19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ Version history

This library adheres to `Semantic Versioning 2.0 <https://semver.org/#semantic-versioning-200>`_.

**2.13.2** (2021-11-23)

- Fixed ``typing_extensions`` being imported unconditionally on Python < 3.9
(bug introduced in 2.13.1)

**2.13.1** (2021-11-23)

- Fixed ``@typechecked`` replacing abstract properties with regular properties
Expand Down
10 changes: 7 additions & 3 deletions src/typeguard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ def is_typeddict(tp) -> bool:

return isinstance(tp, _TypedDictMeta)
else:
def is_typeddict(tp) -> bool:
try:
from typing_extensions import _TypedDictMeta

return isinstance(tp, _TypedDictMeta)
except ImportError:
def is_typeddict(tp) -> bool:
return False
else:
def is_typeddict(tp) -> bool:
return isinstance(tp, _TypedDictMeta)


if TYPE_CHECKING:
Expand Down

0 comments on commit 4615f19

Please sign in to comment.