Skip to content

Commit 4f47303

Browse files
committed
Vendor removed typing._allowed_types
1 parent a11d284 commit 4f47303

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fastcore/basics.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
# %% ../nbs/01_basics.ipynb
3434
defaults = SimpleNamespace()
3535

36+
_allowed_types = (types.FunctionType, types.BuiltinFunctionType,
37+
types.MethodType, types.ModuleType,
38+
WrapperDescriptorType, MethodWrapperType, MethodDescriptorType)
39+
3640
# %% ../nbs/01_basics.ipynb
3741
def ifnone(a, b):
3842
"`b` if `a` is None else `a`"
@@ -352,7 +356,7 @@ def _eval_type(t, glb, loc):
352356

353357
def type_hints(f):
354358
"Like `typing.get_type_hints` but returns `{}` if not allowed type"
355-
if not isinstance(f, typing._allowed_types): return {}
359+
if not isinstance(f, _allowed_types): return {}
356360
ann,glb,loc = get_annotations_ex(f)
357361
return {k:_eval_type(v,glb,loc) for k,v in ann.items()}
358362

0 commit comments

Comments
 (0)