Skip to content

[types] Add __signature__ to FunctionType - #16768

Open
sumit-2007-git wants to merge 3 commits into
python:mainfrom
sumit-2007-git:fix/functiontype-signature
Open

sumit-2007-git wants to merge 3 commits into
python:mainfrom
sumit-2007-git:fix/functiontype-signature

Conversation

@sumit-2007-git

Copy link
Copy Markdown

Fixes #13953.

Adds __signature__: Signature | None to types.FunctionType per PEP 362 and @srittau's guidance in #13953.

Verification

  • inspect._signature_from_callable checks obj.__signature__ and skips it when None (assigning either an inspect.Signature or None works at runtime in CPython).
  • Tested locally with mypy, pyright (stricter), ty, pyrefly, stubtest on types, regr_test, ruff, black, flake8, and check_typeshed_structure.py.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

function is lacking a __signature__ attribute

1 participant