Skip to content
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

Disable Dataset iteration and membership operations (raise error on __iter__ and __contains__) #1384

Merged
merged 4 commits into from
Nov 12, 2024

Conversation

RandallPittmanOrSt
Copy link
Contributor

@RandallPittmanOrSt RandallPittmanOrSt commented Nov 8, 2024

Fixes #1383.

With this change,

for item in dataset:
    ...

raises TypeError: Dataset is not iterable.

Any

if item in dataset:
    ...

raises TypeError: Dataset does not support membership operations. Perhaps try 'varname in dataset.variables' or 'dimname in dataset.dimensions'.

@RandallPittmanOrSt RandallPittmanOrSt marked this pull request as ready for review November 8, 2024 21:40
@RandallPittmanOrSt RandallPittmanOrSt changed the title Disable dataset iteration and membership operations Disable Dataset iteration and membership operations (error on __iter__ and __contains__) Nov 9, 2024
@RandallPittmanOrSt RandallPittmanOrSt changed the title Disable Dataset iteration and membership operations (error on __iter__ and __contains__) Disable Dataset iteration and membership operations (raise error on __iter__ and __contains__) Nov 9, 2024
@jswhit2
Copy link
Contributor

jswhit2 commented Nov 12, 2024

Would be nice to support the iteration, but agree this is useful in the interim since the error message is much clearer. Merging now...

@jswhit jswhit merged commit 4e994e7 into Unidata:master Nov 12, 2024
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Attempts to iterate or perform a membership oepration on a Dataset returns a confusing error.
3 participants