Skip to content

Fix parsing of unquoted hash characters in CLI arguments - #730

Open
MateehUllah wants to merge 2 commits into
google:masterfrom
MateehUllah:fix/preserve-hash-cli-arguments-619
Open

MateehUllah wants to merge 2 commits into
google:masterfrom
MateehUllah:fix/preserve-hash-cli-arguments-619

Conversation

@MateehUllah

Copy link
Copy Markdown

Summary

Fixes #619

This PR fixes an issue where Python Fire incorrectly removes parts of command-line arguments containing unquoted # characters.

For example, passing qgm#123 previously resulted in qgm. With this change, the original argument is preserved.

Changes

  • Updated fire/parser.py to detect unquoted hash characters using Python's tokenizer.
  • Prevented the literal parser from treating these characters as comments.
  • Preserved existing parsing behavior for quoted strings, lists, and dictionaries.
  • Added regression tests in fire/parser_test.py to cover the affected cases.

Testing

Added test cases covering:

  • Unquoted arguments such as qgm#123 and a#b#c.
  • Arguments beginning with #.
  • Quoted hash characters inside lists and dictionaries.

The isolated parsing checks passed. The full test suite has not yet been run.

Files Changed

  • fire/parser.py
  • fire/parser_test.py

Related Issue

Fixes #619

This branch has not been deployed

No deployments
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.

Everything after the # character gets stripped down from string argument

1 participant