-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Stricter mypy config #5738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Stricter mypy config #5738
Conversation
Also edited my previous changelog entry to streamline typehint entries a bit.
I'll try to look at this in more detail at some point (right now, I'm not very familiar with most of mypy's options). In general, in my opinion, we should eventually set most of these. Probably rather sooner than later. For example, when looking at your PR #5701, I realized that almost all callers of the plugin interface are not in fact typed right now. Thus, we get very little feedback from mypy at this point. I'm uncertain about Last time I ran mypy with |
You're right that most plugins don’t fully leverage type hints yet. Before merging additional typing-related PRs like #5734 or #5716, I thought it might be worth configuring some stricter mypy options now. That way, we can avoid having to do another round of refactors later just to adapt to those settings. I realize enabling more options—like --check-untyped-defs—can make a lot of existing issues visible all at once, which can definitely feel overwhelming. But we don’t have to fix everything immediately, especially since mypy isn't currently blocking PRs. In some cases, we could even ignore certain new errors temporarily. Looking ahead, I think it's useful to start moving toward these stricter checks for new code, even if some legacy code doesn’t yet meet the same standard. It's okay if some parts lag behind a bit as long as we keep improving incrementally. |
Description
Since we are working a lot on type hints at the moment, how about we review the available mypy configuration options and decide on a standard setup going forward?
This is meant as a discussion to align on which settings we want to adopt to improve our code quality, type safety, and overall developer experience.
Proposal
I propose enabling the following options:
allow_redefinition = true
check_untyped_defs = true
disallow_incomplete_defs = true
disallow_any_generics = true
List
,Dict
, etc. Avoids untyped containers which can mask bugs or make type inference harder.disallow_untyped_decorators = true
Me can even go stricter (e.g.
disallow_untyped_calls
,warn_unused_ignores
) or more lenient (e.g. leavecheck_untyped_defs
off). I think the proposed setup strikes a good balance between safety and practicality.Would love to hear thoughts or additions!
This is based on the #5701 PR.