Skip to content

fix: strip inline comments after empty unquoted values#3

Closed
kamransiddiqui wants to merge 1 commit into
mainfrom
gitgot/issue-600-431b5049
Closed

fix: strip inline comments after empty unquoted values#3
kamransiddiqui wants to merge 1 commit into
mainfrom
gitgot/issue-600-431b5049

Conversation

@kamransiddiqui

@kamransiddiqui kamransiddiqui commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Closes theskumar#600.

Change _equal_sign in src/dotenv/parser.py from make_regex(r'(=[^%5C%5CS%5Cr%5Cn]*)') to make_regex(r'(=)') so whitespace after = is not consumed by the regex. In parse_unquoted_value, change re.sub(r'%5Cs+#.*', '', part).rstrip() to re.sub(r'%5Cs+#.*', '', part).strip() to remove leading whitespace that now remains part of the raw value. Together these prevent inline comments from being included as the value when a key has an empty unquoted value followed by whitespace and a comment, such as a= #c or a= %5Ct #c.

  • Commit: fe754f9ba7e4

Iterate

gh pr checkout theskumar/python-dotenv

View this request in gitgot to access the live sandbox shell, review the agent's prompt, and request revisions:

431b5049-a65a-485f-9265-1ba7f5a34004


Draft PR opened by gitgot. Mark ready for review once you've verified the change.

Verification: ✅ Passed — gitgot ran the repo’s lint/typecheck/build/test in a sandbox; this PR introduces no new failures vs the base branch (any remaining red was already failing on the base).
Issue match: ✅ Addresses the issue (95% confidence) — The diff modifies src/dotenv/parser.py so the _equal_sign regex no longer consumes whitespace after =, leaving spaces/tabs before a # inside the _unquoted_value capture where the existing re.sub(r'\s+#.*', ...) can strip them; it also changes rstrip() to strip() to discard that leading whitespace, and adds tests verifying that a= #c and a= \t #c parse to an empty value.

@kamransiddiqui
kamransiddiqui deleted the gitgot/issue-600-431b5049 branch June 9, 2026 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Inline comment is included as value when key has empty value (KEY= # comment)

1 participant