From e9925d351c1515a56e762b51129534aae6c2f7c7 Mon Sep 17 00:00:00 2001 From: Carl Baillargeon Date: Mon, 19 Aug 2024 13:29:53 -0400 Subject: [PATCH 1/2] fix(anta): Add upper bound on Griffe requirement for v1 (#794) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6cafa5b7f..ecfcba289 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -81,7 +81,7 @@ dev = [ ] doc = [ "fontawesome_markdown", - "griffe", + "griffe >=0.46,<1.0.0", "mike==2.1.3", "mkdocs-autorefs>=0.4.1", "mkdocs-bootswatch>=1.1", From 08e945b5bf1cc110e4200cf45a391c7b284da6ef Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 19 Aug 2024 13:40:37 -0400 Subject: [PATCH 2/2] chore: update ruff requirement from <0.6.0,>=0.5.4 to >=0.5.4,<0.7.0 (#790) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Carl Baillargeon --- .pre-commit-config.yaml | 2 +- asynceapi/aio_portcheck.py | 2 +- pyproject.toml | 2 +- tests/lib/fixture.py | 16 ++++++++-------- tests/units/cli/exec/test_utils.py | 2 +- tests/units/test_device.py | 8 ++++---- tests/units/test_runner.py | 12 ++++++------ 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6f632b99f..75d4388a1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,7 +43,7 @@ repos: - '' - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.7 + rev: v0.6.1 hooks: - id: ruff name: Run Ruff linter diff --git a/asynceapi/aio_portcheck.py b/asynceapi/aio_portcheck.py index 79f4562fa..fd8e7aee2 100644 --- a/asynceapi/aio_portcheck.py +++ b/asynceapi/aio_portcheck.py @@ -33,7 +33,7 @@ # ----------------------------------------------------------------------------- -async def port_check_url(url: URL, timeout: int = 5) -> bool: +async def port_check_url(url: URL, timeout: int = 5) -> bool: # noqa: ASYNC109 """ Open the port designated by the URL given the timeout in seconds. diff --git a/pyproject.toml b/pyproject.toml index ecfcba289..e64ee80df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ dev = [ "pytest-html>=3.2.0", "pytest-metadata>=3.0.0", "pytest>=7.4.0", - "ruff>=0.5.4,<0.6.0", + "ruff>=0.5.4,<0.7.0", "tox>=4.10.0,<5.0.0", "types-PyYAML", "types-pyOpenSSL", diff --git a/tests/lib/fixture.py b/tests/lib/fixture.py index 17943edc3..b0205b8bb 100644 --- a/tests/lib/fixture.py +++ b/tests/lib/fixture.py @@ -58,7 +58,7 @@ } -@pytest.fixture() +@pytest.fixture def device(request: pytest.FixtureRequest) -> Iterator[AntaDevice]: """Return an AntaDevice instance with mocked abstract method.""" @@ -78,7 +78,7 @@ def _collect(command: AntaCommand, *args: Any, **kwargs: Any) -> None: # noqa: yield dev -@pytest.fixture() +@pytest.fixture def test_inventory() -> AntaInventory: """Return the test_inventory.""" env = default_anta_env() @@ -93,7 +93,7 @@ def test_inventory() -> AntaInventory: # tests.unit.test_device.py fixture -@pytest.fixture() +@pytest.fixture def async_device(request: pytest.FixtureRequest) -> AsyncEOSDevice: """Return an AsyncEOSDevice instance.""" kwargs = { @@ -110,7 +110,7 @@ def async_device(request: pytest.FixtureRequest) -> AsyncEOSDevice: # tests.units.result_manager fixtures -@pytest.fixture() +@pytest.fixture def test_result_factory(device: AntaDevice) -> Callable[[int], TestResult]: """Return a anta.result_manager.models.TestResult object.""" # pylint: disable=redefined-outer-name @@ -128,7 +128,7 @@ def _create(index: int = 0) -> TestResult: return _create -@pytest.fixture() +@pytest.fixture def list_result_factory(test_result_factory: Callable[[int], TestResult]) -> Callable[[int], list[TestResult]]: """Return a list[TestResult] with 'size' TestResult instantiated using the test_result_factory fixture.""" # pylint: disable=redefined-outer-name @@ -140,7 +140,7 @@ def _factory(size: int = 0) -> list[TestResult]: return _factory -@pytest.fixture() +@pytest.fixture def result_manager_factory(list_result_factory: Callable[[int], list[TestResult]]) -> Callable[[int], ResultManager]: """Return a ResultManager factory that takes as input a number of tests.""" # pylint: disable=redefined-outer-name @@ -155,7 +155,7 @@ def _factory(number: int = 0) -> ResultManager: # tests.units.cli fixtures -@pytest.fixture() +@pytest.fixture def temp_env(tmp_path: Path) -> dict[str, str | None]: """Fixture that create a temporary ANTA inventory. @@ -169,7 +169,7 @@ def temp_env(tmp_path: Path) -> dict[str, str | None]: return env -@pytest.fixture() +@pytest.fixture # Disabling C901 - too complex as we like our runner like this def click_runner(capsys: pytest.CaptureFixture[str]) -> Iterator[CliRunner]: # noqa: C901 """Return a click.CliRunner for cli testing.""" diff --git a/tests/units/cli/exec/test_utils.py b/tests/units/cli/exec/test_utils.py index ad1a78ab1..f4c0cc5fd 100644 --- a/tests/units/cli/exec/test_utils.py +++ b/tests/units/cli/exec/test_utils.py @@ -23,7 +23,7 @@ # TODO: complete test cases -@pytest.mark.asyncio() +@pytest.mark.asyncio @pytest.mark.parametrize( ("inventory_state", "per_device_command_output", "tags"), [ diff --git a/tests/units/test_device.py b/tests/units/test_device.py index e8a0c5f86..d3c50cc8e 100644 --- a/tests/units/test_device.py +++ b/tests/units/test_device.py @@ -613,7 +613,7 @@ class TestAntaDevice: """Test for anta.device.AntaDevice Abstract class.""" - @pytest.mark.asyncio() + @pytest.mark.asyncio @pytest.mark.parametrize( ("device", "command_data", "expected_data"), ((d["device"], d["command"], d["expected"]) for d in COLLECT_DATA), @@ -693,7 +693,7 @@ def test__eq(self, data: dict[str, Any]) -> None: else: assert device1 != device2 - @pytest.mark.asyncio() + @pytest.mark.asyncio @pytest.mark.parametrize( ("async_device", "patch_kwargs", "expected"), ((d["device"], d["patch_kwargs"], d["expected"]) for d in REFRESH_DATA), @@ -712,7 +712,7 @@ async def test_refresh(self, async_device: AsyncEOSDevice, patch_kwargs: list[di assert async_device.established == expected["established"] assert async_device.hw_model == expected["hw_model"] - @pytest.mark.asyncio() + @pytest.mark.asyncio @pytest.mark.parametrize( ("async_device", "command", "expected"), ((d["device"], d["command"], d["expected"]) for d in ASYNCEAPI_COLLECT_DATA), @@ -745,7 +745,7 @@ async def test__collect(self, async_device: AsyncEOSDevice, command: dict[str, A assert cmd.output == expected["output"] assert cmd.errors == expected["errors"] - @pytest.mark.asyncio() + @pytest.mark.asyncio @pytest.mark.parametrize( ("async_device", "copy"), ((d["device"], d["copy"]) for d in ASYNCEAPI_COPY_DATA), diff --git a/tests/units/test_runner.py b/tests/units/test_runner.py index 955149d09..53d0bf758 100644 --- a/tests/units/test_runner.py +++ b/tests/units/test_runner.py @@ -24,7 +24,7 @@ FAKE_CATALOG: AntaCatalog = AntaCatalog.from_list([(FakeTest, None)]) -@pytest.mark.asyncio() +@pytest.mark.asyncio async def test_runner_empty_tests(caplog: pytest.LogCaptureFixture, test_inventory: AntaInventory) -> None: """Test that when the list of tests is empty, a log is raised. @@ -40,7 +40,7 @@ async def test_runner_empty_tests(caplog: pytest.LogCaptureFixture, test_invento assert "The list of tests is empty, exiting" in caplog.records[0].message -@pytest.mark.asyncio() +@pytest.mark.asyncio async def test_runner_empty_inventory(caplog: pytest.LogCaptureFixture) -> None: """Test that when the Inventory is empty, a log is raised. @@ -55,7 +55,7 @@ async def test_runner_empty_inventory(caplog: pytest.LogCaptureFixture) -> None: assert "The inventory is empty, exiting" in caplog.records[1].message -@pytest.mark.asyncio() +@pytest.mark.asyncio async def test_runner_no_selected_device(caplog: pytest.LogCaptureFixture, test_inventory: AntaInventory) -> None: """Test that when the list of established device. @@ -140,7 +140,7 @@ def side_effect_setrlimit(resource_id: int, limits: tuple[int, int]) -> None: setrlimit_mock.assert_called_once_with(resource.RLIMIT_NOFILE, (16384, 1048576)) -@pytest.mark.asyncio() +@pytest.mark.asyncio @pytest.mark.parametrize( ("tags", "expected_tests_count", "expected_devices_count"), [ @@ -173,7 +173,7 @@ async def test_prepare_tests( assert sum(len(tests) for tests in selected_tests.values()) == expected_tests_count -@pytest.mark.asyncio() +@pytest.mark.asyncio async def test_prepare_tests_with_specific_tests(caplog: pytest.LogCaptureFixture, test_inventory: AntaInventory) -> None: """Test the runner prepare_tests function with specific tests.""" logger.setup_logging(logger.Log.INFO) @@ -187,7 +187,7 @@ async def test_prepare_tests_with_specific_tests(caplog: pytest.LogCaptureFixtur assert sum(len(tests) for tests in selected_tests.values()) == 5 -@pytest.mark.asyncio() +@pytest.mark.asyncio async def test_runner_dry_run(caplog: pytest.LogCaptureFixture, test_inventory: AntaInventory) -> None: """Test that when dry_run is True, no tests are run.