From e197112f0557290b8dc8cc924740c0326993f271 Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Thu, 13 Apr 2023 10:05:31 +0100 Subject: [PATCH] Enable and fix PT checks on ruff (#3278) --- .flake8 | 2 -- pyproject.toml | 5 ++++- src/ansiblelint/testing/fixtures.py | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.flake8 b/.flake8 index 1dccfc61b1..966d510788 100644 --- a/.flake8 +++ b/.flake8 @@ -76,8 +76,6 @@ per-file-ignores = test/*: D102 # flake8-pytest-style -# PT001: -pytest-fixture-no-parentheses = true # PT006: pytest-parametrize-names-type = tuple # PT007: diff --git a/pyproject.toml b/pyproject.toml index 9452f9bd14..d84e2ff3ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -214,13 +214,16 @@ xfail_strict = true markers = ["eco: Tests effects on a set of 3rd party ansible repositories"] [tool.ruff] -# select = ["ALL"] +select = ["PT"] ignore = [ "E501", # we use black ] target-version = "py39" +[tool.ruff.flake8-pytest-style] +parametrize-values-type = "tuple" + [tool.setuptools.dynamic] optional-dependencies.docs = { file = [".config/requirements-docs.txt"] } optional-dependencies.test = { file = [".config/requirements-test.txt"] } diff --git a/src/ansiblelint/testing/fixtures.py b/src/ansiblelint/testing/fixtures.py index 5326f763df..c75c012ea1 100644 --- a/src/ansiblelint/testing/fixtures.py +++ b/src/ansiblelint/testing/fixtures.py @@ -30,13 +30,13 @@ def fixture_default_rules_collection() -> RulesCollection: return RulesCollection(rulesdirs=[DEFAULT_RULESDIR], options=options) -@pytest.fixture +@pytest.fixture() def default_text_runner(default_rules_collection: RulesCollection) -> RunFromText: """Return RunFromText instance for the default set of collections.""" return RunFromText(default_rules_collection) -@pytest.fixture +@pytest.fixture() def rule_runner(request: SubRequest, config_options: Namespace) -> RunFromText: """Return runner for a specific rule class.""" rule_class = request.param