Skip to content

Commit f975fbc

Browse files
authored
Apply pre-commit hooks (#636)
1 parent 3f8b506 commit f975fbc

35 files changed

+1196
-1161
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ source = aiohttp_session, tests
44
omit = site-packages
55

66
[html]
7-
directory = coverage
7+
directory = coverage

.flake8

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[flake8]
22
enable-extensions = G
3-
max-doc-length = 90
4-
max-line-length = 90
3+
max-doc-length = 88
4+
max-line-length = 88
55
select = A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,B901,B902,B903,B950
66
# E226: Missing whitespace around arithmetic operators can help group things together.
77
# E501: Superseeded by B950 (from Bugbear)
88
# E722: Superseeded by B001 (from Bugbear)
99
# W503: Mutually exclusive with W504.
10-
ignore = E226,E501,E722,W503
10+
ignore = N801,N802,N803,E203,E226,E305,W504,E252,E301,E302,E704,W503,W504,F811
1111
per-file-ignores =
1212
# S101: Pytest uses assert
1313
tests/*:S101

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ venv
6060

6161
.mypy_cache
6262

63-
.python-version
63+
.python-version

.isort.cfg

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[settings]
2+
line_length=88
3+
include_trailing_comma=True
4+
multi_line_output=3
5+
force_grid_wrap=0
6+
combine_as_imports=True

.pre-commit-config.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: changelogs-rst
5+
name: changelog filenames
6+
language: fail
7+
entry: >-
8+
Changelog files must be named
9+
####.(bugfix|feature|removal|doc|misc)(.#)?(.rst)?
10+
exclude: >-
11+
^CHANGES/(\.TEMPLATE\.rst|\.gitignore|\d+\.(bugfix|feature|removal|doc|misc)(\.\d+)?(\.rst)?|README\.rst)$
12+
files: ^CHANGES/
13+
- id: changelogs-user-role
14+
name: Changelog files should use a non-broken :user:`name` role
15+
language: pygrep
16+
entry: :user:([^`]+`?|`[^`]+[\s,])
17+
pass_filenames: true
18+
types: [file, rst]
19+
- repo: https://github.com/pre-commit/pre-commit-hooks
20+
rev: 'v4.0.1'
21+
hooks:
22+
- id: check-merge-conflict
23+
- repo: https://github.com/asottile/yesqa
24+
rev: v1.3.0
25+
hooks:
26+
- id: yesqa
27+
- repo: https://github.com/PyCQA/isort
28+
rev: '5.9.3'
29+
hooks:
30+
- id: isort
31+
- repo: https://github.com/psf/black
32+
rev: '21.10b0'
33+
hooks:
34+
- id: black
35+
language_version: python3 # Should be a command that runs python3.6+
36+
- repo: https://github.com/pre-commit/pre-commit-hooks
37+
rev: 'v4.0.1'
38+
hooks:
39+
- id: end-of-file-fixer
40+
exclude: >-
41+
^docs/[^/]*\.svg$
42+
- id: requirements-txt-fixer
43+
exclude: >-
44+
^requirements/constraints[.]txt$
45+
- id: trailing-whitespace
46+
- id: file-contents-sorter
47+
files: |
48+
CONTRIBUTORS.txt|
49+
docs/spelling_wordlist.txt|
50+
.gitignore|
51+
.gitattributes
52+
- id: check-case-conflict
53+
- id: check-json
54+
- id: check-xml
55+
- id: check-executables-have-shebangs
56+
- id: check-toml
57+
- id: check-yaml
58+
- id: debug-statements
59+
- id: check-added-large-files
60+
- id: check-symlinks
61+
- id: fix-byte-order-marker
62+
- id: fix-encoding-pragma
63+
args: ['--remove']
64+
- id: detect-aws-credentials
65+
args: ['--allow-missing-credentials']
66+
- id: detect-private-key
67+
exclude: ^examples/
68+
- repo: https://github.com/asottile/pyupgrade
69+
rev: 'v2.29.0'
70+
hooks:
71+
- id: pyupgrade
72+
args: ['--py36-plus']
73+
- repo: https://github.com/PyCQA/flake8
74+
rev: '4.0.1'
75+
hooks:
76+
- id: flake8
77+
exclude: "^docs/"
78+
- repo: git://github.com/Lucas-C/pre-commit-hooks-markup
79+
rev: v1.0.1
80+
hooks:
81+
- id: rst-linter
82+
files: >-
83+
^[^/]+[.]rst$
84+
exclude: >-
85+
^CHANGES\.rst$

Makefile

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
# Some simple testing tasks (sorry, UNIX only).
22

3-
flake:
4-
flake8
3+
setup:
4+
pip install -r requirements-dev.txt
5+
python -m pre_commit install
56

7+
flake fmt:
8+
python -m pre_commit run --all-files
69

7-
test: flake
10+
11+
test:
812
py.test ./tests/
913

10-
mypy: flake
14+
mypy lint: fmt
1115
mypy
1216

13-
vtest: flake develop
17+
vtest: develop
1418
py.test ./tests/
1519

16-
cov cover coverage: flake
20+
cov cover coverage:
1721
py.test --cov aiohttp_session --cov-report html --cov-report=xml ./tests/
1822
@echo "open file://`pwd`/coverage/index.html"
1923

@@ -37,4 +41,4 @@ doc:
3741
make -C docs html
3842
@echo "open file://`pwd`/docs/_build/html/index.html"
3943

40-
.PHONY: all build venv flake test vtest testloop cov clean doc
44+
.PHONY: all build venv flake test vtest testloop cov clean doc lint

README.rst

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,15 @@ Developing
9494

9595
Install for local development::
9696

97-
$ pip install -r requirements-dev.txt
97+
$ make setup
9898

99-
Run tests with::
99+
Run linters::
100100

101-
$ pytest -sv tests/
101+
$ make lint
102+
103+
Run tests::
104+
105+
$ make test
102106

103107

104108
Third party extensions

0 commit comments

Comments
 (0)