-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
Add type hinting to public-facing API in pandas/core/generic.py #26792 #29543
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
Conversation
| self._clear_item_cache() | ||
|
|
||
| def transpose(self, *args, **kwargs): | ||
| def transpose(self, *args, **kwargs) -> "NDFrame": |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
|
you need to run |
|
|
||
| @property | ||
| def shape(self): | ||
| def shape(self) -> Tuple[int]: |
There was a problem hiding this comment.
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": |
There was a problem hiding this comment.
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
|
closing as stale, some of this has been done, welcome for PRs to continue |
black pandasgit diff upstream/master -u -- "*.py" | flake8 --diff