python / python/mypy

--strict does not include all mypy checks

Open
#14,143 1 comment 10 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

documentation
Dominant language
Python
Stars
20.6k
Forks
3.3k
PR merge metrics
PR metrics pending

Description

When configuring mypy, I mistakenly assumed that --strict included all possible mypy checks (thus being as strict as possible). However, there are a lot of other checks that are not included in --strict, such as --warn-unreachable or disallow_any_unimported = True or even enable_error_code = ignore-without-code.

Can we add a section to --strict's documentation and --help page explaining all of mypy's stricter checks that are not included in --strict? As far as I can tell, these are the missing ones:

[mypy]
strict = True

# Missing:
warn_unreachable = True
disallow_any_expr = True
disallow_any_decorated = True
disallow_any_explicit = True
disallow_any_unimported = True

# Not strictness checks per se, but enforces uniformity for type: ignores.
show_error_codes = True
enable_error_code = ignore-without-code

Additionally, it might be useful to add a --strictest flag that always opts into all of mypy's checks.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the documentation and --help entry points for --strict, then compare their description with the listed checks that are not enabled. Document the omitted checks and the distinction around ignore error codes; treat the proposed --strictest flag as a separate consideration. Done means both --strict references clearly explain the remaining stricter options.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.