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 ? |
Answered by
srittau
Jul 25, 2023
Replies: 2 comments
d: dict[str, str] = vars(arguments)
v: list[int] = d['arg'] # L12In 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 |
0 replies
Answer selected by
dineshbvadhia
|
Ah, that worked. Thank-you :) |
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)hasstrvalues. And then in line 12 you try to assign one of those (supposedly)strvalues to alist[int]. You should change line 11 to either of those: