Skip to content

Commit

Permalink
Add TorchFix linter (#2179)
Browse files Browse the repository at this point in the history
* Add TorchFix linter

* Move comments to separate lines

* Change assert_allclose to assert_close
  • Loading branch information
kit1980 committed Jun 13, 2023
1 parent 8546bbb commit 60bea66
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
[flake8]
ignore =
E401,E402,E501,E722,W503,W504,F821,B006,B007,B008,B009,
E203 # https://github.com/PyCQA/pycodestyle/issues/373
# https://github.com/PyCQA/pycodestyle/issues/373
E203
select =
B,C,E,F,P,T4,W,B9,
D417 # Missing argument descriptions in the docstring
# Missing argument descriptions in the docstring
D417,
# TorchFix
TOR
max-line-length = 120
exclude = docs/source,third_party
1 change: 1 addition & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ repos:
- id: flake8
additional_dependencies:
- flake8-docstrings == 1.6.0
- torchfix == 0.0.1
args:
- --config=.flake8
6 changes: 3 additions & 3 deletions test/torchtext_unittest/data/test_jit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import torch
from torch.testing import assert_allclose
from torch.testing import assert_close
from torchtext.nn import InProjContainer, MultiheadAttentionContainer, ScaledDotProduct

from ..common.torchtext_test_case import TorchtextTestCase
Expand All @@ -26,5 +26,5 @@ def test_torchscript_multiheadattention(self) -> None:

ts_MHA = torch.jit.script(MHA)
ts_mha_output, ts_attn_weights = ts_MHA(query, key, value, attn_mask=attn_mask)
assert_allclose(mha_output, ts_mha_output)
assert_allclose(attn_weights, ts_attn_weights)
assert_close(mha_output, ts_mha_output)
assert_close(attn_weights, ts_attn_weights)

0 comments on commit 60bea66

Please sign in to comment.