Skip to content

Commit 9e6c116

Browse files
Ananth Subramaniamfacebook-github-bot
authored andcommitted
Add pre-commit linter & formatter
Reviewed By: tangbinh Differential Revision: D38266929 fbshipit-source-id: 76643a3bdfcf26087ac7aa5f35678a598620690d
1 parent c538580 commit 9e6c116

2 files changed

Lines changed: 57 additions & 0 deletions

File tree

.flake8

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[flake8]
2+
# Suggested config from pytorch that we can adopt
3+
select = B,C,E,F,P,T4,W,B9
4+
max-line-length = 120
5+
# C408 ignored because we like the dict keyword argument syntax
6+
# E501 is not flexible enough, we're using B950 instead
7+
ignore =
8+
E203,E305,E402,E501,E721,E741,F405,F821,F841,F999,W503,W504,C408,E302,W291,E303,
9+
# shebang has extra meaning in fbcode lints, so I think it's not worth trying
10+
# to line this up with executable bit
11+
EXE001,
12+
optional-ascii-coding = True
13+
exclude =
14+
./.git,
15+
./docs
16+
./build
17+
./scripts,
18+
./venv,
19+
*.pyi

.pre-commit-config.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
default_language_version:
2+
python: python3
3+
4+
repos:
5+
- repo: https://github.com/pre-commit/pre-commit-hooks
6+
rev: v4.1.0
7+
hooks:
8+
- id: trailing-whitespace
9+
- id: check-ast
10+
- id: check-merge-conflict
11+
- id: no-commit-to-branch
12+
- id: check-added-large-files
13+
args: ['--maxkb=500']
14+
- id: end-of-file-fixer
15+
16+
- repo: https://github.com/Lucas-C/pre-commit-hooks
17+
rev: v1.1.7
18+
hooks:
19+
- id: insert-license
20+
files: \.py$
21+
args:
22+
- --license-filepath
23+
- docs/license_header.txt
24+
25+
- repo: https://github.com/pycqa/flake8
26+
rev: 4.0.1
27+
hooks:
28+
- id: flake8
29+
args:
30+
- --config=.flake8
31+
32+
- repo: https://github.com/omnilib/ufmt
33+
rev: v1.3.0
34+
hooks:
35+
- id: ufmt
36+
additional_dependencies:
37+
- black == 22.3.0
38+
- usort == 1.0.2

0 commit comments

Comments
 (0)