Skip to content

Commit 82c64b4

Browse files
frenzymadnesshroncok
authored andcommitted
Improve %pyproject_check_import newline handling
Add smart newline logic after %pyproject_check_import based on existing %check section content (adds blank line iff %check was multiline). This ensures consistent spec file formatting while avoiding unnecessary blank lines in simple check sections.
1 parent 2a63c7d commit 82c64b4

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

pyprojectize.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,15 @@ def add_pyproject_check_import(spec: Specfile, sections: Sections) -> ResultMsg:
511511
"%check already has %pyproject_check_import",
512512
)
513513

514-
sections.check[:0] = ["%pyproject_check_import", ""]
514+
check_import = ["%pyproject_check_import"]
515+
516+
# Add an empty line after %pyproject_check_import if
517+
# the current content contains more than one line.
518+
if len([l for l in sections.check if l.strip()]) > 1:
519+
check_import += [""]
520+
521+
sections.check[:0] = check_import
522+
515523
return (
516524
Result.UPDATED,
517525
"existing %check prepended with %pyproject_check_import",

tests/__all__.spec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export CYTHON_COMPILE=1
4848

4949
%check
5050
%pyproject_check_import
51-
5251
%{__python3} setup.py test
5352

5453

tests/py3_install_to_pyproject_install__add_pyproject_files__add_pyproject_check_import.spec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ CYTHON_COMPILE=1 %py3_build -- --use-the-force-luke
5151

5252
%check
5353
%pyproject_check_import
54-
5554
%{__python3} setup.py test
5655

5756

0 commit comments

Comments
 (0)