You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add IniConfig.parse() classmethod to fix inline comment handling
Fixes#55 - Inline comments were incorrectly included in parsed values
The bug: Inline comments (# or ;) were being included as part of values
instead of being stripped, inconsistent with how section comments are handled.
Example of the bug:
name = value # comment
Result was: "value # comment" (incorrect)
Should be: "value" (correct)
Changes:
- Add IniConfig.parse() classmethod with strip_inline_comments parameter
- Default: strip_inline_comments=True (correct behavior - strips comments)
- Can set strip_inline_comments=False if old buggy behavior needed
- IniConfig() constructor preserves old behavior for backward compatibility
(calls parse_ini_data with strip_inline_comments=False)
- Add parse_ini_data() helper in _parse.py to avoid code duplication
- Update _parseline() to support strip_inline_comments parameter
- Add comprehensive tests for both correct and legacy behavior
Backward compatibility: Existing code using IniConfig() continues to work
unchanged. Users should migrate to IniConfig.parse() for correct behavior.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
0 commit comments