8000 add pre-commit hook · python-trio/flake8-async@72d937c · GitHub
[go: up one dir, main page]

Skip to content

Commit 72d937c

Browse files
committed
add pre-commit hook
1 parent 033317a commit 72d937c

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
- id: black
1414

1515
- repo: https://github.com/PyCQA/autoflake
16-
rev: v2.0.1
16+
rev: v2.0.2
1717
hooks:
1818
- id: autoflake
1919

@@ -34,7 +34,7 @@ repos:
3434
- id: mypy
3535

3636
- repo: https://github.com/RobertCraigie/pyright-python
37-
rev: v1.1.298
37+
rev: v1.1.299
3838
hooks:
3939
- id: pyright
4040
entry: env PYRIGHT_PYTHON_FORCE_VERSION=latest pyright
@@ -109,7 +109,7 @@ repos:
109109
- id: yamlfmt
110110

111111
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
112-
rev: v2.7.0
112+
rev: v2.8.0
113113
hooks:
114114
- id: pretty-format-toml
115115
args: [--autofix]

.pre-commit-hooks.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- id: flake8_trio
3+
name: flake8_trio
4+
entry: flake8_trio
5+
language: python
6+
types: [python]

flake8_trio/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,16 @@ def main():
109109
all_filenames = [
110110
os.path.join(root, f) for f in all_filenames if _should_format(f)
111111
]
112+
any_error = False
112113
for file in all_filenames:
113114
plugin = Plugin.from_filename(file)
114115
for error in sorted(plugin.run()):
115-
print(f"{file}:{error}")
116+
print(f"{file}:{error}", file=sys.stderr)
117+
any_error = True
116118
if plugin.options.autofix:
117119
with open(file, "w") as file:
118120
file.write(plugin.module.code)
121+
return 1 if any_error else 0
119122

120123

121124
class Plugin:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def local_file(name: str) -> Path:
2929
license="MIT",
3030
description="A highly opinionated flake8 plugin for Trio-related problems.",
3131
zip_safe=False,
32-
install_requires=["flake8"],
32+
install_requires=["flake8", "libcst"],
3333
python_requires=">=3.9",
3434
classifiers=[
3535
"Development Status :: 3 - Alpha",

0 commit comments

Comments
 (0)
0