Skip to content

list('abc') not inferred to be of type List[str] #3395

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

Closed
AbhijeetKrishnan opened this issue Oct 21, 2019 · 3 comments
Closed

list('abc') not inferred to be of type List[str] #3395

AbhijeetKrishnan opened this issue Oct 21, 2019 · 3 comments

Comments

@AbhijeetKrishnan
Copy link

Reference: pandas-dev/pandas#29114 (comment)

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 -

import collections
named_tuple = collections.namedtuple('Test', list('abc'))

Running mypy on the above gives the error error: List or tuple literal expected as the second argument to namedtuple()

@srittau
Copy link
Collaborator

srittau commented Oct 21, 2019

This looks like a mypy error. Both class list and namedtuple() look to be correctly typed in typeshed and should work together. I assume that namedtuple is specially handled by mypy, because of its special semantics.

@AbhijeetKrishnan
Copy link
Author

Would it be more helpful to raise this issue with mypy instead?

@AbhijeetKrishnan
Copy link
Author

I've raised the same issue with mypy (python/mypy#7766) This issue can be closed.

@srittau srittau closed this as completed Oct 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants