-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TYP: define subset
arg in Styler
#41433
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
cc @simonjayhawkins if any comments |
slice_ = [part if pred(part) else [part] for part in slice_] | ||
# error: Item "slice" of "Union[slice, Sequence[Any]]" has no attribute | ||
# "__iter__" (not iterable) -> is specifically list_like in conditional | ||
slice_ = [p if pred(p) else [p] for p in slice_] # type: ignore[union-attr] |
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 you return this directly it should work (as you are re-assigning to a different type)
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.
it wasnt the reassignment it was the fact that slice_ is not always considered to be iterable inside the loop comprehension. Albeit in this clause we have already checked that it is list_like
so is iterable here...
thanks @attack68 if you can create a followon issue to try to integrate this to the rest of pandas; e.g. move Subset to _typing and then use it in .dropna, and so on (e.g. where ever we use a subset argument), may need to add a todo list |
would/could/should this be the same as PositionalIndexer in pandas._typing |
Co-authored-by: JHM Darbyshire (iMac) <[email protected]>
Co-authored-by: JHM Darbyshire (iMac) <[email protected]>
This works but someone with more knowledge might be able to point out a better definition of the type for
Subset
,i.e. here
Subset = Union[slice, Sequence, Index]
It types all the
subset
args inStyler