Repository navigation
Adjust .as_optional_path() to return None for empty strings - #223
Merged
Merged
Conversation
snejus
requested review from
JOJ0 and
amogus07
and
a balanced review from Copilot
October 25, 2026 18:24
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
snejus
force-pushed
the
as-optional-path-empty-string-as-none
branch
from
October 25, 2026 19:16
6f0c0ea to
6b94a72
Compare
JOJ0
requested changes
Oct 30, 2026
JOJ0
left a comment
Member
There was a problem hiding this comment.
You want to make sure that bytes paths stay supported, that is the case. But should an empty bytes path(b"") then also be handled as None?
Not sure if that's very relevant but it would be more consistent, right?
Add early return when value is falsy to handle empty strings consistently with None values. Update docstring to clarify behavior and add test case for empty string input.
snejus
force-pushed
the
as-optional-path-empty-string-as-none
branch
from
October 30, 2026 12:59
6b94a72 to
55fb6f4
Compare
JOJ0
approved these changes
Oct 30, 2026
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
as_optional_path()treated an empty string as a relative path.Filename.valuejoins any non-absolute value with the config/source directory and then callsos.path.abspath, sofoo: ""resolved to that directory itself instead of returningNone(confuse/templates.py:717-738). An empty config entry is almost always "unset", not "point at the config dir".This branch makes
as_optional_path()returnNonefor an empty string, so empty and missing/null values now behave the same (confuse/core.py:334-342).Tests
test_as_optional_pathgains a({"foo": ""}, None)case alongside the existingNoneand missing-key cases (test/test_validation.py:73).