Skip to content

Commit 7c293f7

Browse files
authored
Merge pull request #153 from jakkdl/split_shed
split shed, format&sort toml+yaml
2 parents 665b0cd + 1002d65 commit 7c293f7

File tree

6 files changed

+212
-155
lines changed

6 files changed

+212
-155
lines changed

.github/workflows/ci.yml

Lines changed: 52 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,59 @@
1+
---
12
name: flake8-trio CI
23

34
on:
4-
push:
5-
branches: [ main ]
6-
pull_request:
7-
branches: [ main ]
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
89

910
jobs:
10-
check:
11-
runs-on: ubuntu-latest
12-
steps:
13-
- uses: actions/checkout@v3
14-
- name: Set up Python 3.11
15-
uses: actions/setup-python@v3
16-
with:
17-
python-version: "3.11"
18-
- name: Install dependencies
19-
run: |
20-
python -m pip install --upgrade pip setuptools pre-commit
21-
- name: Run checks
22-
run: |
23-
pre-commit run --all-files
11+
check:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v3
15+
- name: Set up Python 3.11
16+
uses: actions/setup-python@v3
17+
with:
18+
python-version: '3.11'
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
2425
25-
test:
26-
runs-on: ubuntu-latest
27-
strategy:
28-
matrix:
29-
python-version: ["3.9", "3.10", "3.11"]
30-
fail-fast: false
31-
steps:
32-
- uses: actions/checkout@v3
33-
- name: Set up Python ${{ matrix.python-version }}
34-
uses: actions/setup-python@v3
35-
with:
36-
python-version: ${{ matrix.python-version }}
37-
- name: Install dependencies
38-
run: |
39-
python -m pip install --upgrade pip setuptools tox
40-
python -m tox --notest --recreate -e flake8_5,flake8_6
41-
- name: Run tests
42-
run: python -m tox -e flake8_5,flake8_6
26+
test:
27+
runs-on: ubuntu-latest
28+
strategy:
29+
matrix:
30+
python-version: ['3.9', '3.10', '3.11']
31+
fail-fast: false
32+
steps:
33+
- uses: actions/checkout@v3
34+
- name: Set up Python ${{ matrix.python-version }}
35+
uses: actions/setup-python@v3
36+
with:
37+
python-version: ${{ matrix.python-version }}
38+
- name: Install dependencies
39+
run: |
40+
python -m pip install --upgrade pip setuptools tox
41+
python -m tox --notest --recreate -e flake8_5,flake8_6
42+
- name: Run tests
43+
run: python -m tox -e flake8_5,flake8_6
4344

44-
release:
45-
runs-on: ubuntu-latest
46-
needs: [check, test]
47-
if: github.repository == 'Zac-HD/flake8-trio' && github.ref == 'refs/heads/main'
48-
steps:
49-
- uses: actions/checkout@v3
50-
- name: Set up Python 3
51-
uses: actions/setup-python@v3
52-
- name: Install tools
53-
run: python -m pip install --upgrade build pip setuptools wheel twine
54-
- name: Upload new release
55-
env:
56-
TWINE_USERNAME: '__token__'
57-
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
58-
run: python -m build && twine upload --skip-existing dist/*
45+
release:
46+
runs-on: ubuntu-latest
47+
needs: [check, test]
48+
if: github.repository == 'Zac-HD/flake8-trio' && github.ref == 'refs/heads/main'
49+
steps:
50+
- uses: actions/checkout@v3
51+
- name: Set up Python 3
52+
uses: actions/setup-python@v3
53+
- name: Install tools
54+
run: python -m pip install --upgrade build pip setuptools wheel twine
55+
- name: Upload new release
56+
env:
57+
TWINE_USERNAME: __token__
58+
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
59+
run: python -m build && twine upload --skip-existing dist/*

.pre-commit-config.yaml

Lines changed: 99 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,110 @@
1-
# not necessary as Zac-HD/flake8-trio don't currently run pre-commit as an app
2-
# but keeping it for forks, or in case that changes
1+
---
2+
default_language_version:
3+
python: python3.11
4+
# pyright requires internet connection to run, which the pre-commit ci app doesn't have.
5+
# Not used in this repo.
36
ci:
4-
skip: [pyright]
7+
skip: [pyright]
58

69
repos:
7-
- repo: https://github.com/Zac-HD/shed
8-
rev: 2023.3.1
9-
hooks:
10-
- id: shed
11-
args: ['--py39-plus']
10+
- repo: https://github.com/psf/black
11+
rev: 23.1.0
12+
hooks:
13+
- id: black
1214

13-
- repo: https://github.com/RobertCraigie/pyright-python
14-
rev: v1.1.298
15-
hooks:
16-
- id: pyright
17-
entry: env PYRIGHT_PYTHON_FORCE_VERSION=latest pyright
18-
args: ['--pythonversion=3.11', '--warnings']
19-
additional_dependencies:
15+
- repo: https://github.com/PyCQA/autoflake
16+
rev: v2.0.1
17+
hooks:
18+
- id: autoflake
19+
20+
- repo: https://github.com/asottile/pyupgrade
21+
rev: v3.3.1
22+
hooks:
23+
- id: pyupgrade
24+
args: [--py39-plus]
25+
26+
- repo: https://github.com/pycqa/isort
27+
rev: 5.12.0
28+
hooks:
29+
- id: isort
30+
31+
- repo: https://github.com/RobertCraigie/pyright-python
32+
rev: v1.1.298
33+
hooks:
34+
- id: pyright
35+
entry: env PYRIGHT_PYTHON_FORCE_VERSION=latest pyright
36+
args: [--pythonversion=3.11, --warnings]
37+
additional_dependencies:
2038
# Required for pyright strict mode
21-
- hypothesis
22-
- hypothesmith
23-
- pytest
24-
- flake8
25-
- trio
26-
- anyio
39+
- anyio
40+
- flake8
41+
- hypothesis
42+
- hypothesmith
43+
- pytest
44+
- trio
2745

28-
- repo: https://github.com/codespell-project/codespell
29-
rev: v2.2.3
30-
hooks:
31-
- id: codespell
32-
additional_dependencies:
33-
- tomli
46+
- repo: https://github.com/codespell-project/codespell
47+
rev: v2.2.4
48+
hooks:
49+
- id: codespell
50+
additional_dependencies:
51+
- tomli
3452

35-
- repo: https://github.com/pre-commit/pre-commit-hooks
36-
rev: v4.4.0
37-
hooks:
38-
- id: trailing-whitespace
39-
args: ['--markdown-linebreak-ext=md,markdown']
40-
- id: end-of-file-fixer
41-
- id: fix-encoding-pragma
42-
args: [--remove]
43-
- id: check-yaml
44-
- id: debug-statements
45-
language_version: python3
53+
- repo: https://github.com/pre-commit/pre-commit-hooks
54+
rev: v4.4.0
55+
hooks:
56+
- id: check-merge-conflict
57+
- id: check-toml
58+
- id: check-yaml
59+
- id: debug-statements
60+
language_version: python3
61+
- id: end-of-file-fixer
62+
- id: fix-encoding-pragma
63+
args: [--remove]
64+
- id: trailing-whitespace
65+
args: ['--markdown-linebreak-ext=md,markdown']
4666

47-
- repo: https://github.com/PyCQA/flake8
48-
rev: 6.0.0
49-
hooks:
50-
- id: flake8
51-
types: ["python", "pyi"]
52-
language_version: python3
53-
additional_dependencies:
54-
- flake8-builtins
55-
- flake8-bugbear
56-
- flake8-comprehensions
57-
- flake8-2020
58-
- flake8-builtins
59-
- flake8-bugbear
60-
- flake8-comprehensions
61-
- flake8-datetimez
62-
- flake8-docstrings
63-
- flake8-mutable
64-
- flake8-noqa
65-
- flake8-pie
66-
- flake8-pytest-style
67-
- flake8-return
68-
- flake8-simplify
69-
- flake8-type-checking
70-
- flake8-pyi
67+
- repo: https://github.com/PyCQA/flake8
68+
rev: 6.0.0
69+
hooks:
70+
- id: flake8
71+
types_or: [python, pyi]
72+
language_version: python3
73+
additional_dependencies:
74+
- flake8-2020
75+
- flake8-bugbear
76+
- flake8-builtins
77+
- flake8-comprehensions
78+
- flake8-datetimez
79+
- flake8-docstrings
80+
- flake8-mutable
81+
- flake8-noqa
82+
- flake8-pie
83+
- flake8-pyi
84+
- flake8-pytest-style
85+
- flake8-return
86+
- flake8-simplify
87+
- flake8-type-checking
7188

7289
# Pinned to flake8 5.0.4 since flake8-eradicate is not updated to work with flake8 6
7390
# https://github.com/wemake-services/flake8-eradicate/pull/271
74-
- repo: https://github.com/PyCQA/flake8
75-
rev: 5.0.4
76-
hooks:
77-
- id: flake8
78-
args: ["--select=E800"]
79-
language_version: python3
80-
additional_dependencies:
81-
- flake8-eradicate
91+
- repo: https://github.com/PyCQA/flake8
92+
rev: 5.0.4
93+
hooks:
94+
- id: flake8
95+
name: flake8-eradicate
96+
args: [--select=E800]
97+
language_version: python3
98+
additional_dependencies:
99+
- flake8-eradicate
100+
101+
- repo: https://github.com/jumanjihouse/pre-commit-hook-yamlfmt
102+
rev: 0.2.2
103+
hooks:
104+
- id: yamlfmt
105+
106+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
107+
rev: v2.7.0
108+
hooks:
109+
- id: pretty-format-toml
110+
args: [--autofix]

flake8_trio/visitors/__init__.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@
2020

2121
# Import all visitors so their decorators run, filling the above containers
2222
# This has to be done at the end to avoid circular imports
23-
from . import visitor_utility # isort: skip
24-
from . import visitor100 # isort: skip
25-
from . import visitor101 # isort: skip
26-
from . import visitor102 # isort: skip
27-
from . import visitor103_104 # isort: skip
28-
from . import visitor105 # isort: skip
29-
from . import visitor111 # isort: skip
30-
from . import visitor118 # isort: skip
31-
from . import visitor2xx # isort: skip
32-
from . import visitor91x # isort: skip
33-
from . import visitors # isort: skip
23+
from . import (
24+
visitor2xx,
25+
visitor91x,
26+
visitor100,
27+
visitor101,
28+
visitor102,
29+
visitor103_104,
30+
visitor105,
31+
visitor111,
32+
visitor118,
33+
visitor_utility,
34+
visitors,
35+
)

pyproject.toml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
1-
[tool.pyright]
2-
strict = ["*.py", "tests/*.py", "flake8_trio/**/*.py"]
3-
exclude = ["**/node_modules", "**/__pycache__", "**/.*"]
4-
reportUnusedCallResult=false
5-
reportUninitializedInstanceVariable=true
6-
reportPropertyTypeMismatch=true
7-
reportMissingSuperCall=true
8-
reportImplicitStringConcatenation=true
9-
reportCallInDefaultInitializer=true
10-
reportShadowedImports=true
1+
[tool.autoflake]
2+
exclude = ["tests/autofix_files/*.py", "tests/eval_files/*.py"]
3+
ignore-init-module-imports = true
4+
in-place = true
5+
quiet = true
6+
remove-all-unused-imports = true
7+
remove-duplicate-keys = true
8+
remove-unused-variables = true
119

1210
[tool.codespell]
1311
ignore-words-list = 'spawnve'
12+
13+
[tool.isort]
14+
only_modified = true
15+
profile = "black"
16+
py_version = "311"
17+
quiet = true
18+
skip_gitignore = true
19+
skip_glob = "tests/eval_files/*"
20+
21+
[tool.pyright]
22+
exclude = ["**/node_modules", "**/__pycache__", "**/.*"]
23+
reportCallInDefaultInitializer = true
24+
reportImplicitStringConcatenation = true
25+
reportMissingSuperCall = true
26+
reportPropertyTypeMismatch = true
27+
reportShadowedImports = true
28+
reportUninitializedInstanceVariable = true
29+
reportUnusedCallResult = false
30+
strict = ["*.py", "tests/*.py", "flake8_trio/**/*.py"]

tests/test_all_visitors_imported.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,17 @@ def test_all_visitors_imported():
1616
f.stem for f in visitor_dir.iterdir() if f.stem.startswith("visitor")
1717
}
1818
visited_files: set[str] = set()
19+
in_import: bool | None = None
1920
with open(visitor_dir / "__init__.py") as f:
2021
for line in f:
21-
if m := re.match(r"from \. import (?P<module>\w*)", line):
22+
if m := re.fullmatch(r"from \. import \(\n", line):
23+
in_import = True
24+
elif in_import and (m := re.fullmatch(r" *(?P<module>\w*),\n", line)):
2225
visited_files.add(m.group("module"))
26+
elif in_import and re.fullmatch(r"\)\n", line):
27+
in_import = False
28+
29+
# check that parsing succeeded
30+
assert in_import is False
31+
2332
assert visitor_files == visited_files

0 commit comments

Comments
 (0)