Skip to content

Validate errors argument in variable, index, and node drops - #11930

Open
yuenlii wants to merge 3 commits into
pydata:mainfrom
yuenlii:validate-errors-arg
Open

yuenlii wants to merge 3 commits into
pydata:mainfrom
yuenlii:validate-errors-arg

Conversation

@yuenlii

@yuenlii yuenlii commented Nov 23, 2026

Copy link
Copy Markdown

Description

Dataset.drop_vars, Dataset.drop_indexes and DataTree.drop_nodes only checked whether errors was "raise". Any other value, including a typo such as errors="raises", was treated like "ignore", so missing names were skipped without a word.

drop, drop_sel and drop_dims already raise a ValueError for an invalid errors value. This PR adds the same check, with the same message, to the three methods that were missing it. DataArray.drop_vars and DataArray.drop_indexes use the Dataset methods, so they are covered too.

I added test_drop_invalid_errors (Dataset and DataArray) and test_drop_nodes_invalid_errors (DataTree), and a note in whats-new.rst. The 30 new test cases fail on main and pass with this change. The three affected test files pass (1443 passed, 55 skipped, 10 xfailed, 2 xpassed), and ruff reports nothing.

Checklist

  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst

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. It wrote the fix and tests at my direction. I read the diff and can explain each change.

yuenlii and others added 3 commits November 23, 2026 11:04
Reject unsupported errors values rather than silently ignoring missing names. Cover Dataset and DataArray drop_vars/drop_indexes and DataTree.drop_nodes.

Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
@github-actions github-actions Bot added the topic-DataTree Related to the implementation of a DataTree class label Nov 23, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-DataTree Related to the implementation of a DataTree class

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant