Enable safe fallback when loading single values - #147
Draft
akaIDIOT wants to merge 4 commits into
Draft
Conversation
akaIDIOT
commented
Aug 7, 2026
| with Path(fpath).open('rt', encoding=encoding or self.encoding) as fp: | ||
| return self.load(fp) | ||
|
|
||
| def loadv(self, string: str) -> typing.Any: |
Member
Author
There was a problem hiding this comment.
Not sure this implementation is entirely kosher, thoughts welcome 🤔
This combined with calling it where singular values are expected does actually fairly transparently solve the issue.
|
Comparing median (lower is better) metric of benchmarks between this PR's target (562ed1c) and the HEAD of this PR (4d54ee9):
(This comment will be updated on subsequent pushes) |
akaIDIOT
commented
Aug 7, 2026
|
|
||
| suffix: str = '' #: the default file path suffix for a configuration file of this Format | ||
| encoding: str = 'utf-8' #: the default text encoding for reading from binary I/O | ||
| value_fallback: Callable[[str], typing.Any] = str #: the fallback 'factory' for unparseable single values |
Member
Author
There was a problem hiding this comment.
Changing this needs a test
akaIDIOT
commented
Aug 10, 2026
|
|
||
| suffix: str = '' #: the default file path suffix for a configuration file of this Format | ||
| encoding: str = 'utf-8' #: the default text encoding for reading from binary I/O | ||
| value_fallback: Callable[[str], typing.Any] = str #: the fallback 'factory' for unparseable single values |
Member
Author
There was a problem hiding this comment.
Alternatively, we could so something like Format(strict=False), where the fallback type is always str. Less explicit, maybe easier to understand?
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.
Uh oh!
There was an error while loading. Please reload this page.