Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix long lines being wrapped with a trailing space #4288

Merged
merged 2 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions src/ansiblelint/yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions test/test_yaml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading