-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: internals.blocks cleanup, typing #27941
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
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.
looks pretty good some minor annotation comments
pandas/core/internals/blocks.py
Outdated
@@ -669,7 +669,7 @@ def convert( | |||
|
|||
return self.copy() if copy else self | |||
|
|||
def _can_hold_element(self, element): | |||
def _can_hold_element(self, element) -> bool: |
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.
element
here should be Any
right? If so I think OK to type as an explicit indication
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.
Note this comment is applicable in a lot of the signatures here
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.
will do
pandas/core/internals/blocks.py
Outdated
@@ -1288,7 +1276,7 @@ def take_nd(self, indexer, axis, new_mgr_locs=None, fill_tuple=None): | |||
else: | |||
return self.make_block_same_class(new_values, new_mgr_locs) | |||
|
|||
def diff(self, n, axis=1): | |||
def diff(self, n: int, axis: int = 1): |
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.
I think can type the return as -> "Block"
here
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.
Think this would still be nice as a follow up or another commit
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.
is using a string here the best practice?
Good to have you back
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.
Thanks! And yea you would want to use a string literal when the return type for a function is a type of the class itself
Mypy and related documentation will refer to this as a forward reference
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.
added
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.
lgtm one comment
Thanks @jbrockmendel |
No description provided.