Skip to content

utils: make tidy() also clean up the first section - #48

Merged
zpetrace merged 1 commit into
candlepin:mainfrom
prownd:utils-make-tidy-also-clean-up-the-first-section-s01
Sep 30, 2026
Merged

zpetrace merged 1 commit into
candlepin:mainfrom
prownd:utils-make-tidy-also-clean-up-the-first-section-s01

Conversation

@prownd

@prownd prownd commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

tidy() started iterating over the top-level lines at index 1, so when a file starts directly with a section header (the common case), that first section was never passed to tidy_section() and its consecutive empty lines were kept:

>>> cfg = INIConfig(StringIO('[a]\nx = 1\n\n\n\ny = 2\n'))
>>> tidy(cfg); str(cfg)
'[a]\nx = 1\n\n\n\ny = 2\n'

Start at index 0 and only compare with the previous line when there is one.

tidy() started iterating over the top-level lines at index 1, so when
a file starts directly with a section header (the common case), that
first section was never passed to tidy_section() and its consecutive
empty lines were kept:

    >>> cfg = INIConfig(StringIO('[a]\nx = 1\n\n\n\ny = 2\n'))
    >>> tidy(cfg); str(cfg)
    '[a]\nx = 1\n\n\n\ny = 2\n'

Start at index 0 and only compare with the previous line when there
is one.

@zpetrace zpetrace left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@zpetrace
zpetrace merged commit 9506595 into candlepin:main Sep 30, 2026
10 checks passed
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.

2 participants