Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[code quality] fix confused flake8 #7309

Merged
merged 2 commits into from
Sep 23, 2020
Merged

Conversation

stas00
Copy link
Contributor

@stas00 stas00 commented Sep 22, 2020

We run black --target-version py35 ... but flake8 doesn't know that we want this specific target-version, 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.

We can now edit out --line-length 119 --target-version py35 from Makefile and the CI jobs, so that we have one config to rule them all. I pushed that change as well.

@sgugger, @LysandreJik

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.
@stas00 stas00 changed the title [code quality] fix confused flake [code quality] fix confused flake8 Sep 22, 2020
@codecov
Copy link

codecov bot commented Sep 22, 2020

Codecov Report

Merging #7309 into master will increase coverage by 0.49%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7309      +/-   ##
==========================================
+ Coverage   81.43%   81.93%   +0.49%     
==========================================
  Files         174      174              
  Lines       33452    33452              
==========================================
+ Hits        27243    27410     +167     
+ Misses       6209     6042     -167     
Impacted Files Coverage Δ
src/transformers/modeling_tf_gpt2.py 71.59% <0.00%> (-23.38%) ⬇️
src/transformers/tokenization_albert.py 70.19% <0.00%> (-23.08%) ⬇️
src/transformers/modeling_gpt2.py 72.31% <0.00%> (-14.52%) ⬇️
src/transformers/modeling_openai.py 72.25% <0.00%> (-10.00%) ⬇️
src/transformers/configuration_gpt2.py 91.89% <0.00%> (-5.41%) ⬇️
src/transformers/modeling_tf_xlm.py 88.37% <0.00%> (-4.87%) ⬇️
src/transformers/modeling_utils.py 84.28% <0.00%> (-2.50%) ⬇️
src/transformers/generation_utils.py 96.92% <0.00%> (-0.28%) ⬇️
src/transformers/modeling_bert.py 88.44% <0.00%> (+0.16%) ⬆️
src/transformers/file_utils.py 83.08% <0.00%> (+0.24%) ⬆️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 656c27c...e06bd68. Read the comment docs.

Copy link
Collaborator

@sgugger sgugger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this!

@sgugger sgugger merged commit df53643 into huggingface:master Sep 23, 2020
@stas00 stas00 deleted the patch-3 branch October 22, 2020 02:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants