diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 2adfe824d8..572b8a08fd 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -72,7 +72,7 @@ jobs: env: # Number of expected test passes, safety measure for accidental skip of # tests. Update value if you add/remove tests. - PYTEST_REQPASS: 889 + PYTEST_REQPASS: 890 steps: - uses: actions/checkout@v4 with: diff --git a/src/ansiblelint/yaml_utils.py b/src/ansiblelint/yaml_utils.py index ec1f4cd80d..cd6749f772 100644 --- a/src/ansiblelint/yaml_utils.py +++ b/src/ansiblelint/yaml_utils.py @@ -1217,6 +1217,10 @@ def _post_process_yaml( lines[index] = spaces + comment full_line_comments.clear() + if line.rpartition(" ")[2] == "\n": + # drop any trailing spaces + lines[i] = line.rstrip() + "\n" + cleaned = line.strip() if not cleaned.startswith("#") and cleaned.endswith("-"): # got an empty list item. drop any trailing spaces. diff --git a/test/test_yaml_utils.py b/test/test_yaml_utils.py index d4c9a302ca..1600d5d4c6 100644 --- a/test/test_yaml_utils.py +++ b/test/test_yaml_utils.py @@ -249,6 +249,12 @@ def load_yaml_formatting_fixtures(fixture_filename: str) -> tuple[str, str, str] None, id="12", ), + pytest.param( + "---\nWSLENV: HOSTNAME:CI:FORCE_COLOR:GITHUB_ACTION:GITHUB_ACTION_PATH/p:GITHUB_ACTION_REPOSITORY:GITHUB_WORKFLOW:GITHUB_WORKSPACE/p:GITHUB_PATH/p:GITHUB_ENV/p:VIRTUAL_ENV/p:SKIP_PODMAN:SKIP_DOCKER\n", + "---\nWSLENV:\n HOSTNAME:CI:FORCE_COLOR:GITHUB_ACTION:GITHUB_ACTION_PATH/p:GITHUB_ACTION_REPOSITORY:GITHUB_WORKFLOW:GITHUB_WORKSPACE/p:GITHUB_PATH/p:GITHUB_ENV/p:VIRTUAL_ENV/p:SKIP_PODMAN:SKIP_DOCKER\n", + None, + id="13", + ), ), ) def test_fmt(before: str, after: str, version: tuple[int, int] | None) -> None: