Callable has no attribute __signature__
Open
Nobody has claimed this yet.
bug
topic-runtime-semantics
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Bug Report
Mypy doesn't understand the __signature__ attribute of functions.
This was a part of #5958 and was now moved to it's own issue.
To Reproduce
import inspect
foo = lambda: None
foo.__signature__ = inspect.signature(foo)
Expected Behavior
Signature attribute exists
Actual Behavior
foo.py:4:1: error: "Callable[[], None]" has no attribute "__signature__" [attr-defined]
Your Environment
- Mypy version used: 0.942
- Mypy command-line flags: none
- Mypy configuration options from
mypy.ini(and other config files): none - Python version used: 3.7.1
- Operating system and version: Linux
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied lambda example with mypy 0.942 and trace how callable attributes are checked. Done when mypy recognizes the signature assignment without reporting an attr-defined error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100