diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4ad2ba0..6d38764 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,35 +34,18 @@ repos: - id: rstcheck additional_dependencies: - tomli==2.0.1 -- repo: https://github.com/asottile/pyupgrade - rev: ce40a160603ab0e7d9c627ae33d7ef3906e2d2b2 # frozen: v3.19.1 - hooks: - - id: pyupgrade - args: [--py39-plus] -- repo: https://github.com/psf/black-pre-commit-mirror - rev: a4920527036bb9a3f3e6055d595849d67d0da066 # frozen: 25.1.0 - hooks: - - id: black - repo: https://github.com/adamchainz/blacken-docs rev: 78a9dcbecf4f755f65d1f3dec556bc249d723600 # frozen: 1.19.1 hooks: - id: blacken-docs additional_dependencies: - black==25.1.0 -- repo: https://github.com/pycqa/isort - rev: c8ab4a5b21bac924d106e3103dd7c979fdd0f9bc # frozen: 6.0.1 +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: 12753357c00c3fb8615100354c9fdc6ab80b044d # frozen: v0.11.10 hooks: - - id: isort - name: isort (python) -- repo: https://github.com/PyCQA/flake8 - rev: 4b5e89b4b108a6c1a000c591d334a99a80d34c7b # frozen: 7.2.0 - hooks: - - id: flake8 - additional_dependencies: - - flake8-bugbear - - flake8-comprehensions - - flake8-logging - - flake8-tidy-imports + - id: ruff-check + args: [ --fix ] + - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy rev: f40886d54c729f533f864ed6ce584e920feb0af7 # frozen: v1.15.0 hooks: diff --git a/pyproject.toml b/pyproject.toml index c45f2f2..2a96d32 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -56,12 +56,42 @@ test = [ "pytest-xdist", ] -[tool.isort] -add_imports = [ - "from __future__ import annotations", +[tool.ruff] +lint.select = [ + # flake8-bugbear + "B", + # flake8-comprehensions + "C4", + # pycodestyle + "E", + # Pyflakes errors + "F", + # isort + "I", + # flake8-simplify + "SIM", + # flake8-tidy-imports + "TID", + # pyupgrade + "UP", + # Pyflakes warnings + "W", ] -force_single_line = true -profile = "black" +lint.ignore = [ + # flake8-bugbear opinionated rules + "B9", + # line-too-long + "E501", + # suppressible-exception + "SIM105", + # if-else-block-instead-of-if-exp + "SIM108", +] +lint.extend-safe-fixes = [ + # non-pep585-annotation + "UP006", +] +lint.isort.required-imports = [ "from __future__ import annotations" ] [tool.pyproject-fmt] max_supported_python = "3.13" diff --git a/src/pytest_randomly/__init__.py b/src/pytest_randomly/__init__.py index e6cd511..fa10578 100644 --- a/src/pytest_randomly/__init__.py +++ b/src/pytest_randomly/__init__.py @@ -6,16 +6,12 @@ import sys from itertools import groupby from types import ModuleType -from typing import Any -from typing import Callable -from typing import TypeVar +from typing import Any, Callable, TypeVar from _pytest.config import Config from _pytest.config.argparsing import Parser from _pytest.nodes import Item -from pytest import Collector -from pytest import fixture -from pytest import hookimpl +from pytest import Collector, fixture, hookimpl if sys.version_info < (3, 10): from importlib_metadata import entry_points @@ -117,9 +113,9 @@ def pytest_configure(config: Config) -> None: seed_value = config.getoption("randomly_seed") if seed_value == "last": - assert hasattr( - config, "cache" - ), "The cacheprovider plugin is required to use 'last'" + assert hasattr(config, "cache"), ( + "The cacheprovider plugin is required to use 'last'" + ) assert config.cache is not None seed = config.cache.get("randomly_seed", default_seed) elif seed_value == "default": diff --git a/tests/test_pytest_randomly.py b/tests/test_pytest_randomly.py index 3165831..b281c69 100644 --- a/tests/test_pytest_randomly.py +++ b/tests/test_pytest_randomly.py @@ -738,7 +738,7 @@ def test_failing_import(testdir): modcol = testdir.getmodulecol("pytest_plugins='xasdlkj',") with pytest.raises(ImportError): - modcol.obj + modcol.obj # noqa: B018 def test_entrypoint_injection(pytester, monkeypatch): diff --git a/tox.ini b/tox.ini index eb4be6c..eb674b7 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,3 @@ commands = -m pytest -p no:randomly {posargs:tests} dependency_groups = test - -[flake8] -max-line-length = 88 -extend-ignore = E203,E501