An argparse nargs problem #1436
Answered
by
srittau
dineshbvadhia
asked this question in
Q&A
-
Running mypy on the test_argparse.py program below generates the error:
test_argparse.py
What is the problem and the correct type for v ? |
Beta Was this translation helpful? Give feedback.
Answered by
srittau
Jul 25, 2023
Replies: 2 comments
-
d: dict[str, str] = vars(arguments)
v: list[int] = d['arg'] # L12 In line 11 (first line above) you are claiming that the dict returned by d = vars(arguments)
d: dict[str, Any] = vars(arguments) # the annotation is redundant, but you might prefer explicit annotations |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
dineshbvadhia
-
Ah, that worked. Thank-you :) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In line 11 (first line above) you are claiming that the dict returned by
vars(arguments)
hasstr
values. And then in line 12 you try to assign one of those (supposedly)str
values to alist[int]
. You should change line 11 to either of those: