Deal better with "def __init__(self)" return type
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
If untyped defs are disallowed, mypy requires that def __init__(self): has an explicit -> None return type, even though normally the return type is optional for __init__. This can be surprising, so it would be better for mypy to produce a special note in this case about why the return type is required even for __init__.
Another idea would be to drop the error message if using --check-untyped-defs, since the explicit return type arguably doesn't add much value.
See #5943 for context.
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 tracing how mypy reports the missing return type for untyped init methods and how --check-untyped-defs affects that diagnostic. Resolve whether the intended behavior is a special explanatory note or suppressing the error, then verify the chosen behavior with regression coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100