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
cdce8p
left a comment
There was a problem hiding this comment.
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
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. |
|
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
_Argumentsclass,mypy_config_fileandcustom_typeshed_dir, can take on a None value, but they are not marked as such. Callingstubtest.parse_optionson 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 xifaras.s@northeastern.edu. 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