Skip to content

Commit dffdf7d

Browse files
authored
use pre-commit.ci, remove workflow step running pre-commit. Add pyright to CI workflow (#204)
* use pre-commit.ci, remove workflow step running pre-commit. Add pyright step to CI workflow.
1 parent bae0a63 commit dffdf7d

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

.github/workflows/ci.yml

+13-10
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,23 @@ on:
88
branches: [main]
99

1010
jobs:
11-
check:
11+
# pyright can't run in pre-commit CI as it requires an internet connection
12+
# so we instead run it directly as a GitHub action
13+
pyright:
1214
runs-on: ubuntu-latest
1315
steps:
1416
- uses: actions/checkout@v4
15-
- name: Set up Python 3.12
17+
- name: Set up Python
1618
uses: actions/setup-python@v5
1719
with:
18-
python-version: '3.12'
19-
- name: Install dependencies
20-
run: |
21-
python -m pip install --upgrade pip setuptools pre-commit
22-
- name: Run checks
23-
run: |
24-
pre-commit run --all-files
20+
cache: pip
21+
- name: Install typing dependencies
22+
run: pip install -r requirements-typing.txt
23+
- uses: jakebailey/pyright-action@v2
24+
with:
25+
# Use exit code of 1 if warnings are reported.
26+
warnings: true
27+
2528

2629
test:
2730
runs-on: ubuntu-latest
@@ -61,7 +64,7 @@ jobs:
6164

6265
release:
6366
runs-on: ubuntu-latest
64-
needs: [check, test]
67+
needs: [pyright, test]
6568
if: github.repository == 'Zac-HD/flake8-trio' && github.ref == 'refs/heads/main'
6669
steps:
6770
- uses: actions/checkout@v4

.pre-commit-config.yaml

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
default_language_version:
33
python: python3.12
44
# pyright requires internet connection to run, which the pre-commit ci app doesn't have.
5-
# Not used in this repo.
5+
# it instead runs in a github action
66
ci:
77
skip: [pyright]
88

@@ -42,9 +42,12 @@ repos:
4242
# ignore warnings about new version being available, no other warnings
4343
# are suppressed by this.
4444
entry: env PYRIGHT_PYTHON_IGNORE_WARNING=true pyright
45-
args: [--pythonversion=3.11, --warnings]
45+
# exit with non-zero on warnings
46+
args: [--warnings]
47+
# Required for pyright strict mode
48+
# Mirrors content of requirements-typing.txt, as pre-commit does not allow
49+
# reading from that for caching reasons.
4650
additional_dependencies:
47-
# Required for pyright strict mode
4851
- anyio
4952
- flake8
5053
- GitPython

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/python-trio/flake8-trio/main.svg)](https://results.pre-commit.ci/latest/github/python-trio/flake8-trio/main)
2+
[![Checked with pyright](https://microsoft.github.io/pyright/img/pyright_badge.svg)](https://microsoft.github.io/pyright/)
13
# flake8-trio
24

35
A highly opinionated flake8 plugin for [Trio](https://github.com/python-trio/trio)-related problems.

pyproject.toml

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ warn_unused_ignores = false
2828

2929
[tool.pyright]
3030
exclude = ["**/node_modules", "**/__pycache__", "**/.*", "tests/eval_files/*", "tests/autofix_files/*"] # TODO: fix errors in eval/autofix files
31+
pythonVersion = "3.12"
3132
reportCallInDefaultInitializer = true
3233
reportImplicitStringConcatenation = false # black generates implicit string concats
3334
reportMissingSuperCall = true

requirements-typing.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
anyio
2+
flake8
3+
GitPython
4+
hypothesis
5+
hypothesmith
6+
pytest
7+
trio

0 commit comments

Comments
 (0)