Skip to content

Make groupby/resample args keyword-only, start groupby_bins deprecation - #11744

Merged
headtr1ck merged 5 commits into
pydata:mainfrom
mohansree14:groupby-kwonly-args
Oct 19, 2026
Merged

headtr1ck merged 5 commits into
pydata:mainfrom
mohansree14:groupby-kwonly-args

Conversation

@mohansree14

@mohansree14 mohansree14 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR finishes the positional-argument deprecation from #9236 for groupby and resample, and starts it for groupby_bins. It covers the "Make the deprecated positional args of groupby, groupby_bins, resample keyword-only" item in #11721.

  • Dataset/DataArray .groupby and .resample: removed @_deprecate_positional_args("v2024.07.0"). Their signatures already have a *, so passing keyword-only args positionally now raises a TypeError. The deprecation message promised this "two releases later".
  • Dataset/DataArray .groupby_bins: groupby, resample: Deprecate some positional args #9236 added the decorator here but not the *, so it never fired. I added * after bins, which makes the decorator start warning, and changed its version to v2026.09.1, the current unreleased version, so the message is accurate. Turning this straight into an error would break users who were never warned, so it's listed under Deprecations instead of Breaking Changes. If you'd rather make group and bins the only positional parameters some other way, or skip the cycle, I'm happy to change it.

In test_multiple_groupers_string, the pytest.warns(FutureWarning) around obj.groupby("labels1", "labels2") is now just pytest.raises(TypeError). The new test_keyword_only_args covers all three methods for both Dataset and DataArray.

Checklist

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.
    • I take responsibility for any AI-generated content in my PR.
      Tools: Claude Code

[This is Claude Code on behalf of Mohansree Vijayakumar]

mohansree14 and others added 2 commits October 16, 2026 00:28
…cation

Passing keyword-only args of groupby and resample positionally has warned
since v2024.07.0 (pydata#9236) and now raises a TypeError. groupby_bins had the
decorator but no `*`, so it never warned; add the `*` so the deprecation
actually starts. Part of pydata#11721.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>

@headtr1ck headtr1ck left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

Comment thread xarray/core/dataset.py Outdated
return DatasetGroupBy(self, rgroupers, restore_coord_dims=restore_coord_dims)

@_deprecate_positional_args("v2024.07.0")
@_deprecate_positional_args("v2026.09.1")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@_deprecate_positional_args("v2026.09.1")
@_deprecate_positional_args("v2026.10.0")

It's already october.

@headtr1ck

Copy link
Copy Markdown
Collaborator

Would you mind ticking the ai box in the PR description?

@headtr1ck
headtr1ck enabled auto-merge (squash) October 18, 2026 18:08
@headtr1ck headtr1ck added the plan to merge Final call for comments label Oct 19, 2026
@headtr1ck
headtr1ck merged commit d6ae873 into pydata:main Oct 19, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants