fix overload defaults for as_index
in groupby
#1321
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These overloads currently show
as_index: Literal[False] = ...
, but that's not quite correct because the default isTrue
https://github.com/pandas-dev/pandas/blob/9597c0397962b228f00805e0750b91d0e5272ce9/pandas/core/frame.py#L9375
If
as_index: Literal[False]
were to be used instead, then mypy would complain that a non-default parameter (as_index
) follows a default one (level
/axis
). Fixing this would require making an extra overload: one for whenas_index
is passed positionally and one for when it's passed by nameGiven that:
as_index
is boolean, so arguably it's a best practice to pass it by name anywayIs it OK to just type if it if it's passed by name? The alternative would be...to bring the number of overloads to 24 🤯 Certainly doable, my preference would be to keep them down and encourage passing
as_index
by name