Skip to content

Commit

Permalink
Pre commit ci update config (#197)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/mirrors-prettier: v3.0.0-alpha.9-for-vscode → v3.0.0](pre-commit/mirrors-prettier@v3.0.0-alpha.9-for-vscode...v3.0.0)
- [github.com/psf/black: 23.3.0 → 23.7.0](psf/black@23.3.0...23.7.0)
- https://github.com/charliermarsh/ruff-pre-commithttps://github.com/astral-sh/ruff-pre-commit
- [github.com/astral-sh/ruff-pre-commit: v0.0.275 → v0.0.280](astral-sh/ruff-pre-commit@v0.0.275...v0.0.280)
- [github.com/streetsidesoftware/cspell-cli: v6.31.0 → v6.31.1](streetsidesoftware/cspell-cli@v6.31.0...v6.31.1)

* Fixes for new ruff

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
cidrblock and pre-commit-ci[bot] authored Jul 31, 2023
1 parent d7f70d7 commit 023d4e5
Showing 1 changed file with 22 additions and 17 deletions.
39 changes: 22 additions & 17 deletions src/tox_ansible/plugin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# cspell:ignore envlist
"""tox plugin to emit a github matrix."""

from __future__ import annotations

import json
import logging
import os
Expand All @@ -10,21 +12,24 @@

from dataclasses import asdict, dataclass, field
from pathlib import Path
from typing import List, Tuple, TypeVar
from typing import TYPE_CHECKING, TypeVar

import yaml

from tox.config.cli.parser import ToxParser
from tox.config.loader.memory import MemoryLoader
from tox.config.loader.section import Section
from tox.config.loader.str_convert import StrConvert
from tox.config.sets import ConfigSet, CoreConfigSet, EnvConfigSet
from tox.config.types import EnvList
from tox.plugin import impl
from tox.session.state import State
from tox.tox_env.python.api import PY_FACTORS_RE


if TYPE_CHECKING:
from tox.config.cli.parser import ToxParser
from tox.config.types import EnvList
from tox.session.state import State


ALLOWED_EXTERNALS = [
"bash",
"cp",
Expand Down Expand Up @@ -59,7 +64,7 @@ def register_config(self: T) -> None:
"""Register the ansible configuration."""
self.add_config(
"skip",
of_type=List[str],
of_type=list,
default=[],
desc="ansible configuration",
)
Expand All @@ -73,13 +78,13 @@ class AnsibleTestConf: # pylint: disable=too-many-instance-attributes
deps: str
setenv: str
skip_install: bool
allowlist_externals: List[str] = field(default_factory=list)
commands_pre: List[str] = field(default_factory=list)
commands: List[str] = field(default_factory=list)
passenv: List[str] = field(default_factory=list)
allowlist_externals: list[str] = field(default_factory=list)
commands_pre: list[str] = field(default_factory=list)
commands: list[str] = field(default_factory=list)
passenv: list[str] = field(default_factory=list)


def custom_sort(string: str) -> Tuple[int, ...]:
def custom_sort(string: str) -> tuple[int, ...]:
"""Convert a env name into a tuple of ints.
In the case of a string, use the ord() of the first two characters.
Expand All @@ -94,7 +99,7 @@ def custom_sort(string: str) -> Tuple[int, ...]:
continue
try:
converted.append(int(part))
except ValueError:
except ValueError: # noqa: PERF203
num_part = "".join((str(ord(char)).rjust(3, "0")) for char in part[0:2])
converted.append(int(num_part))
return tuple(converted)
Expand Down Expand Up @@ -308,7 +313,7 @@ def generate_gh_matrix(env_list: EnvList) -> None:
fileh.write(encoded)


def get_collection_name(galaxy_path: Path) -> Tuple[str, str]:
def get_collection_name(galaxy_path: Path) -> tuple[str, str]:
"""Extract collection information from the galaxy.yml file.
:param galaxy_path: The path to the galaxy.yml file.
Expand Down Expand Up @@ -337,7 +342,7 @@ def conf_commands(
c_namespace: str,
env_conf: EnvConfigSet,
test_type: str,
) -> List[str]:
) -> list[str]:
"""Build the commands for the tox environment.
:param c_name: The collection name.
Expand Down Expand Up @@ -365,7 +370,7 @@ def conf_commands(
def conf_commands_for_integration_unit(
env_conf: EnvConfigSet,
test_type: str,
) -> List[str]:
) -> list[str]:
"""Build the commands for integration and unit tests.
:param env_conf: The tox environment configuration object.
Expand All @@ -389,7 +394,7 @@ def conf_commands_for_sanity(
c_name: str,
c_namespace: str,
env_conf: EnvConfigSet,
) -> List[str]:
) -> list[str]:
"""Add commands for sanity tests.
:param c_name: The collection name.
Expand All @@ -413,7 +418,7 @@ def conf_commands_pre(
env_conf: EnvConfigSet,
c_name: str,
c_namespace: str,
) -> List[str]:
) -> list[str]:
"""Build and install the collection.
:param env_conf: The tox environment configuration object.
Expand Down Expand Up @@ -516,7 +521,7 @@ def conf_deps(env_conf: EnvConfigSet, test_type: str) -> str:
return "\n".join(deps)


def conf_passenv() -> List[str]:
def conf_passenv() -> list[str]:
"""Build the pass environment variables for the tox environment.
:return: The pass environment variables.
Expand Down

0 comments on commit 023d4e5

Please sign in to comment.