gh-118761: Defer import of functools in annotationlib (#132059)

This commit is contained in:
Jelle Zijlstra 2025-04-04 06:42:22 -07:00 committed by GitHub
parent a126cefc17
commit 255eb375a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,7 +3,6 @@
import ast
import builtins
import enum
import functools
import keyword
import sys
import types
@ -765,9 +764,10 @@ def get_annotations(
if hasattr(unwrap, "__wrapped__"):
unwrap = unwrap.__wrapped__
continue
if isinstance(unwrap, functools.partial):
unwrap = unwrap.func
continue
if functools := sys.modules.get("functools"):
if isinstance(unwrap, functools.partial):
unwrap = unwrap.func
continue
break
if hasattr(unwrap, "__globals__"):
obj_globals = unwrap.__globals__