]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.14] gh-132493: Remove __annotations__ usage in inspect._signature_is_functionlike...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 26 May 2025 08:22:14 +0000 (10:22 +0200)
committerGitHub <noreply@github.com>
Mon, 26 May 2025 08:22:14 +0000 (08:22 +0000)
commitdc441efbd00b8dd2f26d014fb67895d381a8f602
tree7a85fa2261565c097da1f280c5ccdfeb9f1348b4
parent1ce68f6297560c3d22169f0280a516b79375e947
[3.14] gh-132493: Remove __annotations__ usage in inspect._signature_is_functionlike (GH-133415) (#133796)

gh-132493: Remove __annotations__ usage in inspect._signature_is_functionlike (GH-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.
(cherry picked from commit cb6596c6aa30c8c3213c8746d5590e6e2757a6c1)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
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]