MAINT: Check for shadowing and mutable defaults#12380
Merged
larsoner merged 9 commits intomne-tools:mainfrom Jan 23, 2024
Merged
MAINT: Check for shadowing and mutable defaults#12380larsoner merged 9 commits intomne-tools:mainfrom
larsoner merged 9 commits intomne-tools:mainfrom
Conversation
larsoner
commented
Jan 23, 2024
| r"iteritems is deprecated.*Use \.items instead\.", | ||
| "is_categorical_dtype is deprecated.*", | ||
| "The default of observed=False.*", | ||
| "When grouping with a length-1 list-like.*", |
Member
Author
There was a problem hiding this comment.
Member
|
thank you for tackling this. The shadowed imports have been bugging me lately and I was hoping to get around to it this week. 🙏🏻 |
drammock
approved these changes
Jan 23, 2024
Member
drammock
left a comment
There was a problem hiding this comment.
changes look good, I didn't notice anything weird. Two thoughts:
- a utility function
param = convert_none_default_to(param, mutable_default)might be nice (but seems low priority) - is it worth it to someday change the param names in the public API that are shadowing built-ins? e.g.
id,format
Member
Author
I don't think so -- the code paths where we use those is small so low risk of doing something bad, we don't need for example |
larsoner
added a commit
to larsoner/mne-python
that referenced
this pull request
Jan 23, 2024
* upstream/main: MAINT: Check for shadowing and mutable defaults (mne-tools#12380) Bump actions/cache from 3 to 4 (mne-tools#12374) MAINT: Work around pytest issue (mne-tools#12377) [pre-commit.ci] pre-commit autoupdate (mne-tools#12378)
snwnde
pushed a commit
to snwnde/mne-python
that referenced
this pull request
Mar 20, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Enable rules to avoid shadowing builtins (should help with stuff like #12352) and mutable defaults. Found a real bug that could be out there in user code (but hopefully rare!) due to mutable defaults along with added test. Added exceptions/
noqafor things likeformat="nifti"-style kwargs where it doesn't seem like a deprecation cost would be worth the gain of avoiding the shadowing.Pushing with ci skip, will merge
maininto this PR once #12377 lands. Can be reviewed in the meantime if someone wants, though.