Skip to content

Commit

Permalink
core: remove from __future__ import annotations, it breaks doctests :(
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Jan 28, 2023
1 parent 5e442ae commit 3d392bf
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/cachew/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import annotations

from pkg_resources import get_distribution, DistributionNotFound

try:
Expand Down Expand Up @@ -391,7 +389,7 @@ class NTBinder(Generic[NT]):
fields : Sequence[Any] # mypy can't handle cyclic definition at this point :(

@staticmethod
def make(tp: Type[NT], name: Optional[str]=None) -> NTBinder:
def make(tp: Type[NT], name: Optional[str]=None) -> 'NTBinder[NT]':
tp, optional = strip_optional(tp)
union: Optional[Type]
fields: Tuple[Any, ...]
Expand All @@ -418,10 +416,9 @@ def make(tp: Type[NT], name: Optional[str]=None) -> NTBinder:
fields = ()
span = 1
else:
annotations = getattr(tp, '__annotations__', None)
# https://www.python.org/dev/peps/pep-3107/#accessing-function-annotations
if annotations is None or annotations == {}:
raise CachewException(f"{tp}: doesn't look like a supported type to cache. See https://github.com/karlicoss/cachew#features for the list of supported types.")
annotations = typing.get_type_hints(tp)
if annotations == {}:
raise CachewException(f"{tp} (field '{name}'): doesn't look like a supported type to cache. See https://github.com/karlicoss/cachew#features for the list of supported types.")
fields = tuple(NTBinder.make(tp=ann, name=fname) for fname, ann in annotations.items())
span = sum(f.span for f in fields) + (1 if optional else 0)
return NTBinder(
Expand Down

0 comments on commit 3d392bf

Please sign in to comment.