Enable flake8-bugbear line length checking. (#18138)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18138
ghimport-source-id: be62a71ef98714e6f168a00f84120f612363528e

Stack from [ghstack](https://github.com/ezyang/ghstack):
* **#18138 Enable flake8-bugbear line length checking.**

flake8-bugbear's line length checker (B950) which permits violations
of up to 10% but specifies the "true" limit when you go over.

I had to ignore a bunch of flake8-bugbear's other checks when I
turned this on.  They're good checks though (they're turned on
in fbcode) and we should fix them eventually.

Signed-off-by: Edward Z. Yang <ezyang@fb.com>

Reviewed By: salexspb

Differential Revision: D14508678

fbshipit-source-id: 2610ecc0dd43cc0788d77f4d024ebd85b26b8d41
This commit is contained in:
Edward Yang 2019-03-19 13:25:04 -07:00 committed by Facebook Github Bot
parent 794c631e23
commit 916a670828
3 changed files with 12 additions and 5 deletions

View File

@ -1,5 +1,10 @@
[flake8]
select = B,C,E,F,P,T4,W,B9
max-line-length = 120
# C408 ignored because we like the dict keyword argument syntax
ignore = E203,E305,E402,E721,E741,F401,F403,F405,F821,F841,F999,W503,W504,C408
# E501 is not flexible enough, we're using B950 instead
ignore =
E203,E305,E402,E501,E721,E741,F401,F403,F405,F821,F841,F999,W503,W504,C408,
# ignores below are temporary, fix them and remove please!
B005,B006,B007,B008,B902,B903
exclude = docs/src,venv,third_party,caffe2,scripts,docs/caffe2,tools/amd_build/pyHIPIFY,torch/lib/include,torch/lib/tmp_install,build,torch/include

View File

@ -62,8 +62,10 @@ print("z-value: ", z_value)
if z_value >= 3:
raise Exception('''\n
z-value >= 3, there is high chance of perf regression.\n
To reproduce this regression, run `cd .jenkins/pytorch/perf_test/ && bash ''' + test_name + '''.sh` on your local machine and compare the runtime before/after your code change.
''')
To reproduce this regression, run
`cd .jenkins/pytorch/perf_test/ && bash {}.sh` on your local machine
and compare the runtime before/after your code change.
'''.format(test_name))
else:
print("z-value < 3, no perf regression detected.")
if args.update:

View File

@ -23,13 +23,13 @@ matrix:
script: cd .circleci && ./ensure-consistency.py
- name: "Python 2.7 Lint"
python: "2.7"
install: pip install flake8
install: pip install flake8 flake8-bugbear
script: flake8
- name: "Python 3.7 Lint"
python: "3.7"
dist: xenial # required for Python 3.7 (travis-ci/travis-ci#9069)
sudo: required # required for Python 3.7 (travis-ci/travis-ci#9069)
install: pip install flake8-mypy
install: pip install flake8-mypy flake8-bugbear
script: flake8
- name: "MyPy typecheck"
python: "3.6"