Skip to content

Commit

Permalink
Fixed Python 3.5.2 compatibility again
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Nov 17, 2019
1 parent 19b8827 commit cda87ca
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions typeguard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@

try:
from typing import ForwardRef
evaluate_forwardref = ForwardRef._evaluate
except ImportError:
from typing import _ForwardRef as ForwardRef # Python < 3.8
evaluate_forwardref = ForwardRef._eval_type

try:
from inspect import isasyncgenfunction, isasyncgen
Expand Down Expand Up @@ -147,18 +149,11 @@ def __init__(self, func: Callable, frame_locals: Optional[Dict[str, Any]] = None
_type_hints_map[func] = self.type_hints


if sys.version_info < (3, 7):
def resolve_forwardref(maybe_ref, memo: _CallMemo):
if isinstance(maybe_ref, ForwardRef):
return maybe_ref._eval_type(memo.func.__globals__, None)
else:
return maybe_ref
else:
def resolve_forwardref(maybe_ref, memo: _CallMemo):
if isinstance(maybe_ref, ForwardRef):
return maybe_ref._evaluate(memo.func.__globals__, None)
else:
return maybe_ref
def resolve_forwardref(maybe_ref, memo: _CallMemo):
if isinstance(maybe_ref, ForwardRef):
return evaluate_forwardref(maybe_ref, memo.func.__globals__, {})
else:
return maybe_ref


def get_type_name(type_):
Expand Down

0 comments on commit cda87ca

Please sign in to comment.