Skip to content

TYP: misc typing fixes for pandas\core\frame.py #35990

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

Merged
merged 2 commits into from
Aug 31, 2020

Conversation

simonjayhawkins
Copy link
Member

pandas\core\frame.py:1091: error: namedtuple() expects a string literal as the first argument [misc]
pandas\core\frame.py:4594: error: Need type annotation for 'names' (hint: "names: List[] = ...") [var-annotated]

@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Aug 30, 2020
@@ -1088,7 +1088,11 @@ def itertuples(self, index=True, name="Pandas"):
arrays.extend(self.iloc[:, k] for k in range(len(self.columns)))

if name is not None:
itertuple = collections.namedtuple(name, fields, rename=True)
# https://github.com/python/mypy/issues/848
# error: namedtuple() expects a string literal as the first argument [misc]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant do a cast or assert?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, I've got the wrong mypy issue here.

cant do a cast or assert?

no, it has to be a string literal and doesn't look like mypy will change.

see python/mypy#9046 (comment)

we can remove this ignore with Final in Python 3.8 (and a later version of mypy)

@jbrockmendel jbrockmendel merged commit f46ebe8 into pandas-dev:master Aug 31, 2020
@jbrockmendel
Copy link
Member

thanks @simonjayhawkins

@simonjayhawkins simonjayhawkins deleted the pandas-core-frame.py branch August 31, 2020 16:23
jbrockmendel pushed a commit to jbrockmendel/pandas that referenced this pull request Aug 31, 2020
* TYP: misc typing fixes for pandas\core\frame.py

* correct issue number
kesmit13 pushed a commit to kesmit13/pandas that referenced this pull request Nov 2, 2020
* TYP: misc typing fixes for pandas\core\frame.py

* correct issue number
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants