Skip to content

Conversation

@tobyjamez
Copy link

self._clear_item_cache()

def transpose(self, *args, **kwargs):
def transpose(self, *args, **kwargs) -> "NDFrame":
Copy link
Member

Choose a reason for hiding this comment

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

If we start adding type hints to public functions (maybe we already have other places where we do this, but just noticing it here): we should think about what to do with "NDFrame".
This is not a "public term", and IMO no user should see this.

Should it be replaced with a union of Series and Frame?

Copy link
Member

Choose a reason for hiding this comment

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

@simonjayhawkins should this by pd._typing._T?

Copy link
Member

Choose a reason for hiding this comment

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

@simonjayhawkins should this by pd._typing._T?

pd._typing._T is for unbound types (normally objects in a generic container). we should use TypeVar("FrameOrSeries", bound="NDFrame") in core.generic

this is currently pd._typing.FrameOrSeries. some potentially relevant discussion in #29480

This is not a "public term", and IMO no user should see this.

that's a reasonable agrument and perhaps also relevant to #29480

@jbrockmendel
Copy link
Member

you need to run isort pandas/core/generic.py


@property
def shape(self):
def shape(self) -> Tuple[int]:
Copy link
Member

Choose a reason for hiding this comment

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

should this be Tuple[int, ...]?

return self._constructor(new_values, **new_axes).__finalize__(self)

def swapaxes(self, axis1, axis2, copy=True):
def swapaxes(self, axis1: int, axis2: int, copy=True) -> "NDFrame":
Copy link
Member

Choose a reason for hiding this comment

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

int here isnt quite right. I think its pandas._typing.Axis

@jbrockmendel jbrockmendel added the Typing type annotations, mypy/pyright type checking label Dec 3, 2019
@jreback
Copy link
Contributor

jreback commented Jan 1, 2020

closing as stale, some of this has been done, welcome for PRs to continue

@jreback jreback closed this Jan 1, 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.

5 participants