Fix accidental Flake8 excludes (#55178)

Summary:
[Currently](faa4da49ff/.flake8 (L22)), our `.flake8` config file has the `exclude` pattern `scripts`. I'm guessing that this is just meant to exclude the top-level `scripts` dir from Flake8, but it also applies to the following (apparently erroneously):

- `.circleci/scripts`
- `.github/scripts`
- `test/scripts`

This PR corrects the problem by making all the `exclude` patterns (except for the wildcard `*.pyi` pattern) relative to the repository root. Also, since this PR already touches all the `exclude` lines, it also sorts them to help reduce merge conflicts when `.flake8` is edited in the future. This sorting happened to reveal that the `build` pattern was previously present twice, so now it has been deduplicated.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/55178

Test Plan:
Locally:
```
flake8
```
And also [in CI](https://github.com/pytorch/pytorch/pull/55178/checks?check_run_id=2249949511).

Reviewed By: janeyx99

Differential Revision: D27520412

Pulled By: samestep

fbshipit-source-id: 359275c10ca600ee4ce7906e3a7587ffaa4ae1ed
This commit is contained in:
Sam Estep 2021-04-01 16:23:25 -07:00 committed by Facebook GitHub Bot
parent 3575e71be8
commit 047a487b07
3 changed files with 18 additions and 20 deletions

View File

@ -17,7 +17,7 @@ def get_size(file_dir):
# we should only expect one file, if no, something is wrong # we should only expect one file, if no, something is wrong
file_name = glob.glob(os.path.join(file_dir, "*"))[0] file_name = glob.glob(os.path.join(file_dir, "*"))[0]
return os.stat(file_name).st_size return os.stat(file_name).st_size
except: except Exception:
logging.exception(f"error getting file from: {file_dir}") logging.exception(f"error getting file from: {file_dir}")
return 0 return 0
@ -145,5 +145,5 @@ if __name__ == "__main__":
if size != 0: if size != 0:
try: try:
send_message([build_message(size)]) send_message([build_message(size)])
except: except Exception:
logging.exception("can't send message") logging.exception("can't send message")

32
.flake8
View File

@ -14,20 +14,18 @@ ignore =
C400,C401,C402,C403,C404,C405,C407,C411,C413,C414,C415 C400,C401,C402,C403,C404,C405,C407,C411,C413,C414,C415
per-file-ignores = __init__.py: F401 torch/utils/cpp_extension.py: B950 per-file-ignores = __init__.py: F401 torch/utils/cpp_extension.py: B950
exclude = exclude =
docs/src, ./.git,
docs/cpp/src, ./build_code_analyzer,
venv, ./build_test_custom_build,
third_party, ./build,
caffe2, ./caffe2,
scripts, ./docs/caffe2,
docs/caffe2, ./docs/cpp/src,
torch/lib/include, ./docs/src,
torch/lib/tmp_install, ./scripts,
build, ./test/generated_type_hints_smoketest.py,
torch/include, ./third_party,
*.pyi, ./torch/include,
.git, ./torch/lib,
build, ./venv,
build_test_custom_build, *.pyi
build_code_analyzer,
test/generated_type_hints_smoketest.py

View File

@ -108,7 +108,7 @@ else:
# create a fake progress bar that does not display anything # create a fake progress bar that does not display anything
class ProgressbarStub: class ProgressbarStub:
def update(*args): def update(self, *args):
return return
progressbar = ProgressbarStub() progressbar = ProgressbarStub()