Skip to content

Clarified strict documentation #18903

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

Merged
merged 7 commits into from
Apr 17, 2025
Merged

Clarified strict documentation #18903

merged 7 commits into from
Apr 17, 2025

Conversation

lenayoung8
Copy link
Contributor

@lenayoung8 lenayoung8 commented Apr 8, 2025

Fixes #18760

This documentation change basically clarifies strict's behavior as described in the issue, adding precedence of the strict flag with respect to other error-checking flags

Copy link
Collaborator

@sterliakov sterliakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also fixes/improves documentation aspect of #14143. Thanks!


If both strict and strict-included flags are set, strict does not take precedence
nor override corresponding flags. You can see the list of flags enabled by strict
mode in the full :option:`mypy --help` output.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think --warn-unreachable deserves explicit mention here as something many (most?) of the users should be interested in enabling separately. It may become part of --strict in future, but isn't now (see #18078)

Co-authored-by: Stanislav Terliakov <[email protected]>
Comment on lines 760 to 761
If both strict and strict-included flags are set, strict does not take precedence
nor override corresponding flags. You can see the list of flags enabled by strict
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be summarized as "all other error-checking flags have precedence over strict, regardless of the order in which they are passed"?
(that's right, right?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you are right, but I think specifying that only the strict-related flags take precedence makes it clearer because they would be otherwise unrelated/wouldn't override. I have updated it to be:

"The strict flag does not take precedence over other strict-related flags. Directly specifying a flag of alternate behavior will override the behavior of strict, regardless of the order in which they are passed."

Although I was going for clarity, does this still seem too verbose?

Copy link
Collaborator

@sterliakov sterliakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@JukkaL JukkaL merged commit 82d9477 into python:master Apr 17, 2025
2 checks passed
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.

Document that strict does NOT override corresponding flags
4 participants