From 916a670828bad914907f628e88e6c0ca6bb9b365 Mon Sep 17 00:00:00 2001 From: Edward Yang Date: Tue, 19 Mar 2019 13:25:04 -0700 Subject: [PATCH] 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 Reviewed By: salexspb Differential Revision: D14508678 fbshipit-source-id: 2610ecc0dd43cc0788d77f4d024ebd85b26b8d41 --- .flake8 | 7 ++++++- .jenkins/pytorch/perf_test/compare_with_baseline.py | 6 ++++-- .travis.yml | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.flake8 b/.flake8 index b0b5497bfef..7f7c24a0ee1 100644 --- a/.flake8 +++ b/.flake8 @@ -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 diff --git a/.jenkins/pytorch/perf_test/compare_with_baseline.py b/.jenkins/pytorch/perf_test/compare_with_baseline.py index 5518e719513..e4f60013b3e 100644 --- a/.jenkins/pytorch/perf_test/compare_with_baseline.py +++ b/.jenkins/pytorch/perf_test/compare_with_baseline.py @@ -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: diff --git a/.travis.yml b/.travis.yml index 6aa70770fc3..408b69509a8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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"