-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Replace Any
in optparse
#11599
Replace Any
in optparse
#11599
Conversation
This comment has been minimized.
This comment has been minimized.
Regarding the primer output: The pip annotations need to be updated to include |
This comment has been minimized.
This comment has been minimized.
This PR works towards #9550 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worked with optparse internals recently and I got somewhat familiar with it so I decided to leave you some suggestions that I thought could help your PR :)
Co-authored-by: Ali Hamdan <[email protected]>
Diff from mypy_primer, showing the effect of this PR on open source code: pip (https://github.com/pypa/pip)
+ src/pip/_internal/cli/parser.py:70: error: Argument 1 of "format_description" is incompatible with supertype "HelpFormatter"; supertype defines the argument type as "str | None" [override]
+ src/pip/_internal/cli/parser.py:70: note: This violates the Liskov substitution principle
+ src/pip/_internal/cli/parser.py:70: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
+ src/pip/_internal/cli/parser.py:88: error: Argument 1 of "format_epilog" is incompatible with supertype "HelpFormatter"; supertype defines the argument type as "str | None" [override]
+ src/pip/_internal/cli/parser.py:88: note: This violates the Liskov substitution principle
+ src/pip/_internal/cli/parser.py:88: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#incompatible-overrides
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you.
Both mypy primer hits in pip are true positives. Their functions accept None
but are annotated as accepting only str
(see here); I guess they were just following the old optparse annotations.
The first commit replaces some
Any
s with the correct type and should probably be reviewed in isolation.The second commit replaces all remaining
Any
s withIncomplete
(or removes the annotation completely). This may be overzealous, as there might be legitimateAny
s, but I opted for the "safer" side, as I don't have time to review them and they are all a bit suspect.