Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add a pseudo error code, all, which enables all error codes #19048

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

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

wyattscarpenter
Copy link
Contributor

@wyattscarpenter wyattscarpenter commented May 7, 2025

This code change allows users to use --enable-error-code all to enable all error codes. This "fixes" #2376 (which was closed as not planned — but a decade of hindsight has, I think, revealed that the idea for a flag like this is more practical than it initially seemed). It also addresses a feature request that was mentioned in the course of discussing #18078 (it does not fix #18078, which is an issue about something else).

My main motivation to add this feature is that it's very easy to add and somewhat useful to me and others, who sometimes want to see what the effect of enabling all error codes is, whether we decide to check our code with that every time or just want to evaluate all of the codes at once to see which are worthwhile.

I don't think this PR closes further discussion on whether, eg, --strict should also enable every error code, which I also think should be true, but for other reasons; nor what flags should control what other error codes, which is also a fertile grounds for discussion. I conceptualize --enable-error-codes all as sort of a "low-level" command line option that does something simple to define (all), whereas other flags do something more ergonomic like give you some recommended set of error codes.

This code change seems like it should allow not just command line usage but also configuration file usage, but for some opaque reason (perhaps my machine configuration is just cursed?) this did not work for me (it resulted in an "invalid error code" error message). So it's documented as only a command line feature.

The test for this feature spotchecks that --enable-error-code all enabled explicit-override and a couple other errors.

…and line

although I actually have no idea why that would be the case, as the error for using it in configuration seems inexplicable, since it consults the same list of error codes in the end 🤷

This comment has been minimized.

@wyattscarpenter wyattscarpenter marked this pull request as draft May 8, 2025 00:07
…itives.pyi instead

my plan after this, if this doesn't work, is to go to [typing fixtures/typing-full.pyi] ; I'm just blindly trying things

This comment has been minimized.

@wyattscarpenter
Copy link
Contributor Author

OK, I don't really understand the whole situation here with the stubs, but I guess I have to add @overload to a number of them. Whatever they're for.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

github-actions bot commented May 8, 2025

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@wyattscarpenter wyattscarpenter marked this pull request as ready for review May 8, 2025 22:03
@A5rocks
Copy link
Collaborator

A5rocks commented May 9, 2025

IMO this is less discoverable than a flag (e.g. --all-checks) but maybe I'm wrong. I agree the basic idea makes sense though.

@sterliakov
Copy link
Collaborator

Agree with @A5rocks - there was a ticket for --all-checks or a similar flag that is a superset of --strict and enables all our optional codes, I don't think all error code is good. This also introduces a discrepancy: what should # type: ignore[all] do? Does it silence everything like a bare ignore? Is it an error to use such comment at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable --warn-unreachable in --strict in Mypy 2.0
3 participants