-
Notifications
You must be signed in to change notification settings - Fork 1.4k
MAINT: Check for shadowing and mutable defaults #12380
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
Conversation
@@ -1382,6 +1382,7 @@ def reset_warnings(gallery_conf, fname): | |||
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.*", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for tackling this. The shadowed imports have been bugging me lately and I was hoping to get around to it this week. 🙏🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
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 |
* 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)
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/
noqa
for 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
main
into this PR once #12377 lands. Can be reviewed in the meantime if someone wants, though.