Fix: preserve empty inline comments (bare `#`) in imports
isort was stripping empty inline comments from imports, e.g., `import a #`
became `import a`. This was caused by the comment parser returning `""` for
both "no `#`" and "empty comment after `#`", and callers dropping falsy values.
- comments.py: parse() returns None (not "") when no # is present; add_to_line()
handles empty comment strings by outputting bare # without trailing space
- parse.py: use `is not None` checks to distinguish empty from absent comments
- output.py: fix nested comment rendering and combine_straight_imports path
Co-authored-by:
DanielNoord <13665637+DanielNoord@users.noreply.github.com>
Loading
Please register or sign in to comment