Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 8, 2024
1 parent 8beb75a commit 9d719c2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 25 deletions.
38 changes: 18 additions & 20 deletions clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@
"""A test files updater."""

import logging
import ruamel.yaml

from pathlib import Path
from typing import OrderedDict

import ruamel.yaml

from ansiblelint.yaml_utils import FormattedYAML
from ruamel.yaml import CommentedSeq
from ruamel.yaml.comments import CommentedMap
from ruamel.yaml.tokens import CommentToken
from ruamel.yaml.error import CommentMark
from ruamel.yaml.tokens import CommentToken


logging.basicConfig(level=logging.INFO)
LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -111,11 +113,7 @@ def update_include_cli(data: CommentedSeq) -> bool:
:param data: The task list
:return: Whether the include_cli task was updated
"""
match = [
idx
for idx, item in enumerate(data)
if item.get("include") == "cli.yaml"
]
match = [idx for idx, item in enumerate(data) if item.get("include") == "cli.yaml"]
if not match:
return False

Expand All @@ -133,11 +131,7 @@ def update_include_nxapi(data: CommentedSeq) -> bool:
:param data: The task list
:return: Whether the include_nxapi task was updated
"""
match = [
idx
for idx, item in enumerate(data)
if item.get("include") == "nxapi.yaml"
]
match = [idx for idx, item in enumerate(data) if item.get("include") == "nxapi.yaml"]
if not match:
return False

Expand Down Expand Up @@ -192,14 +186,16 @@ def update_include_test_case(list_of_tasks) -> bool:
for idx, item in enumerate(list_of_tasks)
if item.get("include", "").startswith("{{ test_case_to_run }}")
or item.get("ansible.builtin.include_tasks", "").startswith(
"{{ test_case_to_run }}"
"{{ test_case_to_run }}",
)
]
if not match:
return False
for entry in match:
change_key(
list_of_tasks[entry], "include", "ansible.builtin.include_tasks"
list_of_tasks[entry],
"include",
"ansible.builtin.include_tasks",
)
values = (
list_of_tasks[entry]
Expand All @@ -209,13 +205,15 @@ def update_include_test_case(list_of_tasks) -> bool:
)
first, var_pairs = values.split(" ", 1)
list_of_tasks[entry]["ansible.builtin.include_tasks"] = first.replace(
"{{", "{{ "
"{{",
"{{ ",
).replace("}}", " }}")
list_of_tasks[entry]["vars"] = {}
for var_pair in var_pairs.split(" "):
key, value = var_pair.split("=")
list_of_tasks[entry]["vars"][key] = value.replace(
"{{", "{{ "
"{{",
"{{ ",
).replace("}}", " }}")

return True
Expand Down Expand Up @@ -294,13 +292,13 @@ def undo_set_fact_equal(list_of_tasks) -> bool:
commented = True

change_key(
list_of_tasks[entry], "set_fact", "ansible.builtin.set_fact"
list_of_tasks[entry],
"set_fact",
"ansible.builtin.set_fact",
)

if commented:
list_of_tasks[entry]["ansible.builtin.set_fact"].ca.items[
last_key
] = [
list_of_tasks[entry]["ansible.builtin.set_fact"].ca.items[last_key] = [
None,
None,
ct,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ testpaths = ["tests"]
filterwarnings = [
'ignore:AnsibleCollectionFinder has already been configured',
'ignore:_AnsibleCollectionFinder.find_spec().*',
]
]
6 changes: 3 additions & 3 deletions tests/integration/labs/single.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
lab:
description: ''
notes: ''
description: ""
notes: ""
title: nxos test
version: 0.2.0
links:
Expand Down Expand Up @@ -91,4 +91,4 @@ nodes:
label: port
slot: 0
type: physical
annotations: []
annotations: []
2 changes: 1 addition & 1 deletion tests/integration/test_integration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import os
import subprocess

import logging
import pytest


Expand Down

0 comments on commit 9d719c2

Please sign in to comment.