Add IniConfig.parse() with inline comment stripping and Unicode whitespace handling #70
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
This PR adds backward-compatible solutions for issue #55 (inline comment handling) and issue #4 (Unicode whitespace).
Changes
1. Add
IniConfig.parse()
classmethod (Fixes #55)parse()
classmethod withstrip_inline_comments
parameterTrue
- properly strips inline comments from valuesFalse
- preserves old behavior if neededIniConfig()
constructor maintains backward compatibility (doesn't strip comments)IniConfig.parse()
for correct comment handlingExample:
2. Add
strip_section_whitespace
parameter (Addresses #4)IniConfig.parse()
to strip Unicode whitespace from section namesFalse
- preserves existing behaviorTrue
: strips Unicode whitespace (U+00A0, U+2000, U+3000, etc.) from section namesstr.strip()
has handled Unicode whitespace since Python 3.0 (2008)Example:
3. Code Refactoring
__init__
to accept optional_sections
and_sources
parametersparse()
to call constructor with pre-parsed data__new__
logic for cleaner, more maintainable codeparse_ini_data()
helper function to eliminate code duplicationTesting
Documentation
Closes
Fixes #55
Addresses #4 (opt-in solution with full Unicode whitespace documentation)
🤖 Generated with Claude Code