diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4eaa4c1..69c1f10 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,12 @@ on: pull_request: jobs: + ruff: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - uses: astral-sh/ruff-action@v3 + Windows: name: 'Windows (${{ matrix.python }})' runs-on: 'windows-latest' diff --git a/docs/source/conf.py b/docs/source/conf.py index ff74f8b..5611320 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -101,7 +101,7 @@ def setup(app): # built documents. # # The short X.Y version. -import pytest_trio +import pytest_trio # noqa: E402 version = pytest_trio.__version__ # The full version, including alpha/beta/rc tags. @@ -143,7 +143,7 @@ def setup(app): # We have to set this ourselves, not only because it's useful for local # testing, but also because if we don't then RTD will throw away our # html_theme_options. -import sphinx_rtd_theme +import sphinx_rtd_theme # noqa: E402 html_theme = "sphinx_rtd_theme" html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] diff --git a/pyproject.toml b/pyproject.toml index 5225691..9dc7de4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,3 +96,14 @@ partial_branches = [ "if .* or not _t.TYPE_CHECKING:", "if .* or not t.TYPE_CHECKING:", ] + +[tool.ruff] +lint.extend-select = [ + "ASYNC", # flake8-async + "C4", # flake8-comprehensions + "PERF", # Perflint + "PT", # flake8-pytest-style +] +lint.ignore = [ + "ASYNC115", # `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)` +] diff --git a/pytest_trio/__init__.py b/pytest_trio/__init__.py index 5fbd91f..1a281f8 100644 --- a/pytest_trio/__init__.py +++ b/pytest_trio/__init__.py @@ -1,6 +1,6 @@ """Top-level package for pytest-trio.""" -from ._version import __version__ +from ._version import __version__ # noqa: F401 from .plugin import trio_fixture __all__ = ["trio_fixture"] diff --git a/pytest_trio/_tests/test_fixture_mistakes.py b/pytest_trio/_tests/test_fixture_mistakes.py index 7bd38ed..27646ae 100644 --- a/pytest_trio/_tests/test_fixture_mistakes.py +++ b/pytest_trio/_tests/test_fixture_mistakes.py @@ -1,5 +1,5 @@ -import pytest -from pytest_trio import trio_fixture +import pytest # noqa: F401 +from pytest_trio import trio_fixture # noqa: F401 from .helpers import enable_trio_mode diff --git a/pytest_trio/_tests/test_trio_mode.py b/pytest_trio/_tests/test_trio_mode.py index 19efdc1..6cb3501 100644 --- a/pytest_trio/_tests/test_trio_mode.py +++ b/pytest_trio/_tests/test_trio_mode.py @@ -1,4 +1,4 @@ -import pytest +import pytest # noqa: F401 from .helpers import enable_trio_mode @@ -139,7 +139,7 @@ async def test(): def test_closest_explicit_run_wins(testdir): - testdir.makefile(".ini", pytest=f"[pytest]\ntrio_mode = true\ntrio_run = trio\n") + testdir.makefile(".ini", pytest="[pytest]\ntrio_mode = true\ntrio_run = trio\n") testdir.makepyfile(qtrio=qtrio_text) test_text = """ @@ -159,7 +159,7 @@ async def test(): def test_ini_run_wins_with_blank_marker(testdir): - testdir.makefile(".ini", pytest=f"[pytest]\ntrio_mode = true\ntrio_run = qtrio\n") + testdir.makefile(".ini", pytest="[pytest]\ntrio_mode = true\ntrio_run = qtrio\n") testdir.makepyfile(qtrio=qtrio_text) test_text = """ diff --git a/pytest_trio/plugin.py b/pytest_trio/plugin.py index ebfcbee..3bc517c 100644 --- a/pytest_trio/plugin.py +++ b/pytest_trio/plugin.py @@ -283,7 +283,7 @@ async def run(self, test_ctx, contextvars_ctx): for event in self.user_done_events: await event.wait() except BaseException as exc: - assert isinstance(exc, trio.Cancelled) + assert isinstance(exc, trio.Cancelled) # noqa: PT017 yield_outcome = outcome.Error(exc) test_ctx.crash(self, None) with trio.CancelScope(shield=True):