You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
list('abc')does get inferred as being of type List[str]. The issue here is that it is not a list "literal" -- that is, something like ["a", "b", "c"]. mypy needs it to be a literal so that it can easily read off and determine the names of the fields.
It would probably be possible to handle this particular case, but it doesn't seem common enough to be worth doing.
Thank you! mypy's behaviour is confusing me though. The error when the second argument is list('abc') is error: List or tuple literal expected as the second argument to namedtuple(). 'a b c' is neither a list nor a tuple (I believe it is a str). Why does mypy not complain in the latter case?
list('abc')
should be inferred to be of type List[str]. However, we still get errors if used as the argument to a function.MRE
Command used
mypy code.py
Version
mypy 0.720
Python 3.7.4
Actual output
error: List or tuple literal expected as the second argument to namedtuple()
.Expected behaviour
I would expect it to succeed without error.
Reference: pandas-dev/pandas#29114 (comment)
The text was updated successfully, but these errors were encountered: