Improve message if user forgot to call a function
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Forgetting to call a method, i.e. missing (), is a somewhat common programming error. Mypy will typically catch this error, but often error messages includes something like "Callable[...]" has no attribute "foo". Since the callable type may be pretty complicated, this can look confusing.
Here are a few ideas that could make this better:
- Only say
Callable object has no attribute "foo"(omit the full callable type). - Add a note such as
Did you mean ".foo()" (with parentheses)?(needs wordsmithing). - In addition to (1), show the signature of the function in a separate note pretty-printed using function definition syntax such as
def foo() -> List[X].
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
No file or test is named. Start by locating mypy's diagnostic path for a Callable object reported as lacking an attribute, then compare the proposed wording and signature note options. Done means the confusing callable type is presented more clearly and regression coverage verifies the missing-parentheses guidance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100