]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-132493: Remove __annotations__ usage in inspect._signature_is_functionlike (#133415)
authorJelle Zijlstra <jelle.zijlstra@gmail.com>
Sat, 10 May 2025 01:42:53 +0000 (18:42 -0700)
committerGitHub <noreply@github.com>
Sat, 10 May 2025 01:42:53 +0000 (18:42 -0700)
commitcb6596c6aa30c8c3213c8746d5590e6e2757a6c1
tree96196b70708205c3c86fc596b6db80be6c5d90e5
parent1978904a2fc6705303486f35336054d455b5018a
gh-132493: Remove __annotations__ usage in inspect._signature_is_functionlike (#133415)

This check is potentially problematic because it could force evaluation of
annotations unnecessarily. This doesn't trigger for builtin objects (functions,
classes, or modules) with annotations, but it could trigger for third-party objects.

The check was not particularly useful anyway, because it succeeds if ``__annotations__``
is a dict or None, so the only thing this did was guard against objects that have an
``__annotations__`` attribute that is of some other type. That doesn't seem particularly
useful, so I just removed the check.
Lib/inspect.py
Lib/test/test_inspect/test_inspect.py
Misc/NEWS.d/next/Library/2025-05-04-17-04-55.gh-issue-132493.huirKi.rst [new file with mode: 0644]