Skip to content

Commit

Permalink
Fix accidental Flake8 excludes (pytorch#55178)
Browse files Browse the repository at this point in the history
Summary:
[Currently](https://github.com/pytorch/pytorch/blob/faa4da49ff6fdde8411572fe907e861e95ce2c85/.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: pytorch#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
  • Loading branch information
samestep authored and facebook-github-bot committed Apr 1, 2021
1 parent 3575e71 commit 047a487
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .circleci/scripts/upload_binary_size_to_scuba.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get_size(file_dir):
# we should only expect one file, if no, something is wrong
file_name = glob.glob(os.path.join(file_dir, "*"))[0]
return os.stat(file_name).st_size
except:
except Exception:
logging.exception(f"error getting file from: {file_dir}")
return 0

Expand Down Expand Up @@ -145,5 +145,5 @@ def gen_messages():
if size != 0:
try:
send_message([build_message(size)])
except:
except Exception:
logging.exception("can't send message")
32 changes: 15 additions & 17 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,18 @@ ignore =
C400,C401,C402,C403,C404,C405,C407,C411,C413,C414,C415
per-file-ignores = __init__.py: F401 torch/utils/cpp_extension.py: B950
exclude =
docs/src,
docs/cpp/src,
venv,
third_party,
caffe2,
scripts,
docs/caffe2,
torch/lib/include,
torch/lib/tmp_install,
build,
torch/include,
*.pyi,
.git,
build,
build_test_custom_build,
build_code_analyzer,
test/generated_type_hints_smoketest.py
./.git,
./build_code_analyzer,
./build_test_custom_build,
./build,
./caffe2,
./docs/caffe2,
./docs/cpp/src,
./docs/src,
./scripts,
./test/generated_type_hints_smoketest.py,
./third_party,
./torch/include,
./torch/lib,
./venv,
*.pyi
2 changes: 1 addition & 1 deletion test/scripts/run_cuda_memcheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def is_cpu_only(name):

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

Expand Down

0 comments on commit 047a487

Please sign in to comment.