Skip to content

TYP: Add type hint for DataFrame.T and certain array types #32532

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 1 commit into from
Mar 11, 2020

Conversation

qwhelan
Copy link
Contributor

@qwhelan qwhelan commented Mar 7, 2020

While updating a large pandas codebase with type coverage to 1.0, I noticed that DataFrame.transpose() is annotated to return DataFrame while DataFrame.T has no such hint. This PR also adds hints in a few places other places where they're trivial.

The definition of pandas.core.base.IndexOpsMixIn.transpose (and associated .T) currently do not have any type hints and fixing this seems more complicated, meaning Index.T and Series.T are not fixed by this PR.

Happy to amend to cover that case if anyone has suggestions, but I believe DataFrame.T to be the vast majority of usage.

  • closes #xxxx
  • tests added / passed
  • passes black pandas
  • passes git diff upstream/master -u -- "*.py" | flake8 --diff
  • whatsnew entry

@qwhelan qwhelan force-pushed the transpose_type branch 2 times, most recently from eeb0417 to de3c999 Compare March 8, 2020 00:14
@simonjayhawkins simonjayhawkins added the Typing type annotations, mypy/pyright type checking label Mar 10, 2020
@simonjayhawkins simonjayhawkins added this to the 1.1 milestone Mar 10, 2020
Copy link
Member

@WillAyd WillAyd left a comment

Choose a reason for hiding this comment

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

@jreback jreback merged commit 817d57d into pandas-dev:master Mar 11, 2020
@jreback
Copy link
Contributor

jreback commented Mar 11, 2020

thanks @qwhelan

SeeminSyed pushed a commit to CSCD01-team01/pandas that referenced this pull request Mar 22, 2020
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.

4 participants