Prevent None extension parameters from crashing putup#510
Merged
Conversation
As shown in #506, ConfigUpdater will crash when trying to persist `option = None`. These changes implement a workaround for that.
Pull Request Test Coverage Report for Build 5350649215844352
💛 - Coveralls |
Member
|
Thanks @abravalheri! |
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.
Purpose
As shown in #506, ConfigUpdater will crash when trying to persist
option = None.This is problematic when an extension defines a "persitible" parameter that can assume
None, since it may crash putup.These changes implement a workaround for that.
Approach
Force the parameter to be persisted as an empty string instead of None?
This might be controversial, but it is the safest approach for an
INIformat, sinceINIfiles are opaque in terms of types for option values (in the end of the day they are always strings and it is up for the users to interpret those strings the way they see fit).Alternative (not implemented) and Cons:
We could use
allow_no_value=True, however other tools using thesetup.cfg(e.g. setuptools, isort, pytest, mypy, etc...), might not like this (the default value forallow_no_valuein ConfigParser isFalse), and therefore parser errors might crash them.