Skip to content

Commit ee4a6fa

Browse files
committed
GitHub Actions :Lint Python code with ruff
1 parent ad8f76f commit ee4a6fa

File tree

7 files changed

+26
-9
lines changed

7 files changed

+26
-9
lines changed

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ on:
77
pull_request:
88

99
jobs:
10+
ruff:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v5
14+
- uses: astral-sh/ruff-action@v3
15+
1016
Windows:
1117
name: 'Windows (${{ matrix.python }})'
1218
runs-on: 'windows-latest'

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def setup(app):
101101
# built documents.
102102
#
103103
# The short X.Y version.
104-
import pytest_trio
104+
import pytest_trio # noqa: E402
105105

106106
version = pytest_trio.__version__
107107
# The full version, including alpha/beta/rc tags.
@@ -143,7 +143,7 @@ def setup(app):
143143
# We have to set this ourselves, not only because it's useful for local
144144
# testing, but also because if we don't then RTD will throw away our
145145
# html_theme_options.
146-
import sphinx_rtd_theme
146+
import sphinx_rtd_theme # noqa: E402
147147

148148
html_theme = "sphinx_rtd_theme"
149149
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]

pyproject.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,14 @@ partial_branches = [
9696
"if .* or not _t.TYPE_CHECKING:",
9797
"if .* or not t.TYPE_CHECKING:",
9898
]
99+
100+
[tool.ruff]
101+
lint.extend-select = [
102+
"ASYNC", # flake8-async
103+
"C4", # flake8-comprehensions
104+
"PERF", # Perflint
105+
"PT", # flake8-pytest-style
106+
]
107+
lint.ignore = [
108+
"ASYNC115", # `trio.lowlevel.checkpoint()` instead of `trio.sleep(0)`
109+
]

pytest_trio/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Top-level package for pytest-trio."""
22

3-
from ._version import __version__
3+
from ._version import __version__ # noqa: F401
44
from .plugin import trio_fixture
55

66
__all__ = ["trio_fixture"]

pytest_trio/_tests/test_fixture_mistakes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import pytest
2-
from pytest_trio import trio_fixture
1+
import pytest # noqa: F401
2+
from pytest_trio import trio_fixture # noqa: F401
33

44
from .helpers import enable_trio_mode
55

pytest_trio/_tests/test_trio_mode.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import pytest
1+
import pytest # noqa: F401
22

33
from .helpers import enable_trio_mode
44

@@ -139,7 +139,7 @@ async def test():
139139

140140

141141
def test_closest_explicit_run_wins(testdir):
142-
testdir.makefile(".ini", pytest=f"[pytest]\ntrio_mode = true\ntrio_run = trio\n")
142+
testdir.makefile(".ini", pytest="[pytest]\ntrio_mode = true\ntrio_run = trio\n")
143143
testdir.makepyfile(qtrio=qtrio_text)
144144

145145
test_text = """
@@ -159,7 +159,7 @@ async def test():
159159

160160

161161
def test_ini_run_wins_with_blank_marker(testdir):
162-
testdir.makefile(".ini", pytest=f"[pytest]\ntrio_mode = true\ntrio_run = qtrio\n")
162+
testdir.makefile(".ini", pytest="[pytest]\ntrio_mode = true\ntrio_run = qtrio\n")
163163
testdir.makepyfile(qtrio=qtrio_text)
164164

165165
test_text = """

pytest_trio/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ async def run(self, test_ctx, contextvars_ctx):
283283
for event in self.user_done_events:
284284
await event.wait()
285285
except BaseException as exc:
286-
assert isinstance(exc, trio.Cancelled)
286+
assert isinstance(exc, trio.Cancelled) # noqa: PT017
287287
yield_outcome = outcome.Error(exc)
288288
test_ctx.crash(self, None)
289289
with trio.CancelScope(shield=True):

0 commit comments

Comments
 (0)