fix: allow None for addplot and alines kwargs in plot()#696
Open
Jo2234 wants to merge 1 commit intomatplotlib:masterfrom
Open
fix: allow None for addplot and alines kwargs in plot()#696Jo2234 wants to merge 1 commit intomatplotlib:masterfrom
Jo2234 wants to merge 1 commit intomatplotlib:masterfrom
Conversation
The validators for 'addplot' and 'alines' kwargs rejected None values, even though None is the documented default. This caused a TypeError when users explicitly passed addplot=None or alines=None (e.g. when conditionally building plot arguments). The fix adds 'value is None or' to both validators so they accept None, matching the Default value and the existing None-checks in the plot() function body (lines 421, 740, 659). Fixes matplotlib#681
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.
Summary
Fix
addplotandalineskwarg validators to acceptNone, matching their documented default values.Problem
When users conditionally build plot arguments and explicitly pass
addplot=Noneoralines=None, aTypeErroris raised because the validators don't acceptNone:This is a common pattern when conditionally building kwargs:
Fix
Both kwargs already have
'Default': Noneand theplot()function body already checks forNone(lines 421, 659, 740), so this fix makes the validators consistent.Fixes #681