-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Correct type annotations on two fields in _Arguments that are optional but are not marked as such #16897
Correct type annotations on two fields in _Arguments that are optional but are not marked as such #16897
Conversation
…l but are not marked as such
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.
The change looks correct. The code already handles the None
case, so it's not an issue in reality. Nevertheless good to change it.
Just to satisfy the typing, could you adjust the abspath
call a few lines below?
Lines 1923 to 1925 in 517f5ae
options.custom_typeshed_dir = args.custom_typeshed_dir | |
if options.custom_typeshed_dir: | |
options.abs_custom_typeshed_dir = os.path.abspath(args.custom_typeshed_dir) |
if options.custom_typeshed_dir:
- options.abs_custom_typeshed_dir = os.path.abspath(args.custom_typeshed_dir)
+ options.abs_custom_typeshed_dir = os.path.abspath(options.custom_typeshed_dir)
@cdce8p just saw your comment right after I pushed a change to resolve the type error. Instead of making the change you suggested, I changed the if condition to check if |
I would suggest to use the value from Lines 1926 to 1929 in 517f5ae
|
…to os.path.abspath
@cdce8p Makes sense, thanks. Made the change you suggested. |
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! Thanks @sam-xif 👍🏻
Thanks! |
Hello mypy team,
I am working as part of a research team developing a code analysis tool for Python. One of the issues the tool discovered in mypy's codebase is that two fields in the
_Arguments
class,mypy_config_file
andcustom_typeshed_dir
, can take on a None value, but they are not marked as such. Callingstubtest.parse_options
on an empty list of arguments reproduces the situation where these two fields are None.If you are interested in learning more about the tool and how it found this issue, let me know down in the comments, or you can contact me at [email protected]. If you find that this issue is not legitimate, I would be interested in understanding why.
Note that I did not add any test cases as no functional changes to the code were made.
Thank you for your consideration!
-Sam