diff --git a/.config/requirements-test.txt b/.config/requirements-test.txt index db7b8840c5..f62fa707e1 100644 --- a/.config/requirements-test.txt +++ b/.config/requirements-test.txt @@ -3,6 +3,7 @@ ansible-lint >= 6.12.1 black check-jsonschema coverage[toml] +docker >= 7.1.0 # testing filelock >= 3.9.0 mypy pexpect >= 4.8.0, < 5 diff --git a/.config/requirements.in b/.config/requirements.in index 5aee011d12..cbe4d25be9 100644 --- a/.config/requirements.in +++ b/.config/requirements.in @@ -1,5 +1,5 @@ ansible-compat >= 24.6.1 -ansible-core >= 2.12.10 +ansible-core >= 2.15.0 click >= 8.0, < 9 click-help-colors enrich >= 1.2.7 diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 7ab04e9b7c..cdf37d494b 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -18,4 +18,5 @@ jobs: tox: uses: ansible/team-devtools/.github/workflows/tox.yml@main with: + default_python: "3.10" # for lint other_names_also: "eco" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ecd36aa3d0..942388dfed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,6 +4,8 @@ ci: autoupdate_commit_msg: "chore: pre-commit autoupdate" autoupdate_schedule: monthly autofix_commit_msg: "chore: auto fixes from pre-commit.com hooks" +default_language_version: + python: python3.10 # minimal we support officially for consistent results repos: - repo: https://github.com/pre-commit/pre-commit-hooks @@ -98,7 +100,7 @@ repos: - wcmatch - repo: https://github.com/pre-commit/mirrors-mypy.git - rev: v1.11.2 + rev: v1.13.0 hooks: - id: mypy additional_dependencies: @@ -133,7 +135,6 @@ repos: --strip-extras --output-file=.config/constraints.txt pyproject.toml files: ^.config\/.*requirements.*$ - language_version: "3.10" # minimal we support officially - repo: https://github.com/ansible/ansible-lint rev: v24.9.2 hooks: diff --git a/collections/requirements.yml b/collections/requirements.yml index baa1672646..6b56f82e65 100644 --- a/collections/requirements.yml +++ b/collections/requirements.yml @@ -3,6 +3,6 @@ collections: - name: community.crypto - name: community.docker - version: ">=3.10.2" + version: ">=3.10.4" - name: containers.podman - name: kubernetes.core diff --git a/pyproject.toml b/pyproject.toml index d1e8c43f9e..d3b6f87217 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,6 +76,7 @@ cache_dir = "./.cache/.mypy" # To ensure that calling `mypy .` produces desired results (vscode) exclude = ["build"] files = ["src", "tests"] +python_version = "3.10" strict = true [[tool.mypy.overrides]] @@ -92,6 +93,7 @@ baseline = ".config/pydoclint-baseline.txt" check-return-types = false check-yield-types = false exclude = '\.cache|\.git|\.tox|build|out|venv' +quiet = true # no need to print out the files being checked should-document-private-class-attributes = true show-filenames-in-every-violation-message = true skip-checking-short-docstrings = false @@ -354,6 +356,9 @@ verbosity_assertions = 2 [tool.ruff] builtins = ["__"] cache-dir = "./.cache/.ruff" +external = [ + "DOC" # pydoclint +] fix = true line-length = 100 target-version = "py310" diff --git a/src/molecule/scenarios.py b/src/molecule/scenarios.py index c3ce62f95c..7fa18f8c3f 100644 --- a/src/molecule/scenarios.py +++ b/src/molecule/scenarios.py @@ -28,8 +28,6 @@ if TYPE_CHECKING: - from typing import Self - from molecule.config import Config from molecule.scenario import Scenario @@ -55,7 +53,7 @@ def __init__( self._scenario_name = scenario_name self._scenarios = self.all - def __iter__(self) -> Self: + def __iter__(self) -> Scenarios: """Make object iterable. Returns: diff --git a/tests/conftest.py b/tests/conftest.py index ccea46c65d..50c6026587 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -66,6 +66,21 @@ def is_subset(subset, superset): # type: ignore[no-untyped-def] # noqa: ANN001 return subset == superset +@pytest.fixture(autouse=True) +def _no_color(monkeypatch: pytest.MonkeyPatch) -> None: + """Disable coloring output. + + Args: + monkeypatch: pytest.MonkeyPatch. + """ + # Analyzing output with no color is much easier. Tests that need to test for + # color output, should override the value. + monkeypatch.setitem(os.environ, "NO_COLOR", "1") + monkeypatch.delitem(os.environ, "PY_COLORS", raising=False) + monkeypatch.delitem(os.environ, "ANSIBLE_FORCE_COLOR", raising=False) + monkeypatch.delitem(os.environ, "FORCE_COLOR", raising=False) + + @pytest.fixture() def resources_folder_path() -> Path: """Return the path to the resources folder. diff --git a/tests/fixtures/integration/test_command/molecule/docker/requirements.yml b/tests/fixtures/integration/test_command/molecule/docker/requirements.yml index dd9657c44d..37237b9911 100644 --- a/tests/fixtures/integration/test_command/molecule/docker/requirements.yml +++ b/tests/fixtures/integration/test_command/molecule/docker/requirements.yml @@ -1,3 +1,3 @@ collections: - name: community.docker - version: ">=3.10.2" + version: ">=3.10.4" diff --git a/tests/integration/test_command.py b/tests/integration/test_command.py index a015e912c8..638ce2bbb4 100644 --- a/tests/integration/test_command.py +++ b/tests/integration/test_command.py @@ -344,4 +344,5 @@ def test_smoke(monkeypatch: pytest.MonkeyPatch, test_fixture_dir: Path) -> None: """ monkeypatch.chdir(test_fixture_dir) command = ["molecule", "test", "--scenario-name", "smoke"] - assert run_command(command).returncode == 0 + result = run_command(command) + assert result.returncode == 0, result diff --git a/tests/unit/model/v2/conftest.py b/tests/unit/model/v2/conftest.py index 227b6b9809..2665e87979 100644 --- a/tests/unit/model/v2/conftest.py +++ b/tests/unit/model/v2/conftest.py @@ -29,7 +29,7 @@ if TYPE_CHECKING: from pathlib import Path - from typing import Any, LiteralString + from typing import Any @pytest.fixture(name="molecule_file") @@ -69,7 +69,7 @@ def config(molecule_file: Path, request: pytest.FixtureRequest) -> dict[str, Any @pytest.fixture() -def _model_platforms_delegated_section_data() -> LiteralString: +def _model_platforms_delegated_section_data() -> str: return """ --- platforms: diff --git a/tests/unit/test_logger.py b/tests/unit/test_logger.py index 1a870aea5a..069a2e5219 100644 --- a/tests/unit/test_logger.py +++ b/tests/unit/test_logger.py @@ -105,6 +105,7 @@ def test_markup_detection_pycolors0(monkeypatch): # type: ignore[no-untyped-def def test_markup_detection_pycolors1(monkeypatch): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, D103 + monkeypatch.delenv("NO_COLOR", raising=False) monkeypatch.setenv("PY_COLORS", "1") assert should_do_markup()