Skip to content
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

With the most recent pandas-stubs, mypy now complains about every call to itertuples() #834

Closed
Dr-Irv opened this issue Dec 19, 2023 · 3 comments · Fixed by #842
Closed

Comments

@Dr-Irv
Copy link
Collaborator

Dr-Irv commented Dec 19, 2023

With the most recent pandas-stubs, mypy now complains about every call to itertuples()
Is there a way that I'm supposed to tell the new release what my column names are?

Sample

import pandas as pd                                                                                 
                                                                                                    
df = pd.DataFrame({"a": [1, 2, 3, 4], "b": [5, 6, 7, 8]})                                           
                                                                                                    
for item in df.itertuples():                                                                        
    a = item.a                                                                                      
    b = item.b     
mypy.....................................................................Failed
- hook id: mypy
- exit code: 1

foo.py:6: error: "tuple[Any, ...]" has no attribute "a"  [attr-defined]
foo.py:7: error: "tuple[Any, ...]" has no attribute "b"  [attr-defined]
Found 2 errors in 1 file (checked 1 source file)

Originally posted by @j-carson in #832

@twoertwein twoertwein mentioned this issue Dec 24, 2023
2 tasks
@roj516
Copy link

roj516 commented Feb 26, 2024

With the new type mypy complains whenever it is passed to a function accepting NamedTuple :-(

error: Argument n to "foo" has incompatible type "_PandasNamedTuple"; expected "NamedTuple"  [arg-type]

@Dr-Irv
Copy link
Collaborator Author

Dr-Irv commented Feb 26, 2024

With the new type mypy complains whenever it is passed to a function accepting NamedTuple :-(

error: Argument n to "foo" has incompatible type "_PandasNamedTuple"; expected "NamedTuple"  [arg-type]

@roj516 can you create a new issue and a more complete example?

@roj516
Copy link

roj516 commented Feb 27, 2024

With the new type mypy complains whenever it is passed to a function accepting NamedTuple :-(

error: Argument n to "foo" has incompatible type "_PandasNamedTuple"; expected "NamedTuple"  [arg-type]

@roj516 can you create a new issue and a more complete example?

881

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

Successfully merging a pull request may close this issue.

2 participants