https://github.com/python/cpython/commit/255eb375a7cc3cb16698bebf42689e8bc783ed93 commit: 255eb375a7cc3cb16698bebf42689e8bc783ed93 branch: main author: Jelle Zijlstra <jelle.zijls...@gmail.com> committer: JelleZijlstra <jelle.zijls...@gmail.com> date: 2025-04-04T06:42:22-07:00 summary:
gh-118761: Defer import of functools in annotationlib (#132059) files: M Lib/annotationlib.py diff --git a/Lib/annotationlib.py b/Lib/annotationlib.py index c08cd4d66589b6..c42dad3503bff7 100644 --- a/Lib/annotationlib.py +++ b/Lib/annotationlib.py @@ -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__ _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com