-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
TYP: check_untyped_defs core.groupby.ops #36921
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
TYP: check_untyped_defs core.groupby.ops #36921
Conversation
@@ -866,7 +866,7 @@ def _is_indexed_like(obj, axes, axis: int) -> bool: | |||
# Splitting / application | |||
|
|||
|
|||
class DataSplitter: |
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.
does this allow us to be more specific in _get_sorted_data or _chop below?
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.
yes, in general if the return type of a method is dependant on self.data and using the FrameOrSeries TypeVar.
we covered this before #29456 (review)
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 guess more specific: is it worth doing that 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.
I think so, but the subsequent changes proved controversial last time.
atm. This PR just 'ties' the output of _get_sorted_data
which is typed with the FrameOrSeries TypeVar with self.data.
hence 'Revealed type is 'FrameOrSeries`1'
for sdata
and mypy no longer reports pandas\core\groupby\ops.py:889: error: Need type annotation for 'sdata' [var-annotated]
the return type of _get_sorted_data is the same as self.data.take. And Series.take returns a Series and DataFrame.take returns a DataFrame. (i.e. same type as caller)
(As an aside, take is defined in NDFrame and Series and similar for other indexing methods. What's the policy regarding method placement? Could they be moved from NDFrame to DataFrame if overridden in Series?)
will circle back round to this (if not merged b4) and add a commit with some more types to take advantage of making DataSplitter generic. If too controversial, can always roll back.
thanks @simonjayhawkins |
pandas\core\groupby\ops.py:889: error: Need type annotation for 'sdata' [var-annotated]