Should we eventually type check all function bodies by default?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
One of the more surprising mypy features is that is doesn't type check functions without annotations (see #6643 for an example). New users are particularly likely to hit this issue, but it's generally easy to forget to annotate functions, especially those that don't take any arguments. Maybe we should type check all function bodies by default, and provide an option to fall back to the current behavior. We've made this behavior quite prominent in the documentation, but it still seems to confuse many users.
We'd probably want to reduce the number of false positives before making the switch, but this is something the mypy core team is planning to work on anyway. It may be useful to try to infer the return type automatically as well for this to provide the most benefits.
Thoughts?
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 reading the behavior described here and the example in issue #6643, then review the documentation that explains unchecked function bodies. The issue does not name implementation files or tests; done would require a decided approach for default checking, an option for the current behavior, and reduced false positives, with tests and documentation updated accordingly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100