Skip to content

Commit df53643

Browse files
authoredSep 23, 2020
[code quality] fix confused flake8 (huggingface#7309)
* fix confused flake We run `black --target-version py35 ...` but flake8 doesn't know that, so currently with py38 flake8 fails suggesting that black should have reformatted 63 files. Indeed if I run: ``` black --line-length 119 --target-version py38 examples templates tests src utils ``` it indeed reformats 63 files. The only solution I found is to create a black config file as explained at https://github.com/psf/black#configuration-format, which is what this PR adds. Now flake8 knows that py35 is the standard and no longer gets confused regardless of the user's python version. * adjust the other files that will now rely on black's config file
1 parent 78387cc commit df53643

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed
 

‎.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ jobs:
244244
key: v0.3-code_quality-{{ checksum "setup.py" }}
245245
paths:
246246
- '~/.cache/pip'
247-
- run: black --check --line-length 119 --target-version py35 examples templates tests src utils
247+
- run: black --check examples templates tests src utils
248248
- run: isort --check-only examples templates tests src utils
249249
- run: flake8 examples templates tests src utils
250250
- run: python utils/check_copies.py

‎Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Check that source code meets quality standards
44

55
quality:
6-
black --check --line-length 119 --target-version py35 examples templates tests src utils
6+
black --check examples templates tests src utils
77
isort --check-only examples templates tests src utils
88
flake8 examples templates tests src utils
99
python utils/check_copies.py
@@ -12,7 +12,7 @@ quality:
1212
# Format source code automatically
1313

1414
style:
15-
black --line-length 119 --target-version py35 examples templates tests src utils
15+
black examples templates tests src utils
1616
isort examples templates tests src utils
1717

1818
# Make marked copies of snippets of codes conform to the original

‎pyproject.toml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[tool.black]
2+
line-length = 119
3+
target-version = ['py35']

0 commit comments

Comments
 (0)
Please sign in to comment.