From 2cbd35da70381099819d53c2fed62962ba8ed904 Mon Sep 17 00:00:00 2001 From: Sergii Dymchenko Date: Mon, 12 Jun 2023 17:40:18 -0700 Subject: [PATCH 1/3] Add TorchFix linter --- .flake8 | 3 ++- .pre-commit-config.yaml | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.flake8 b/.flake8 index e09b485892..25fd0e7c89 100644 --- a/.flake8 +++ b/.flake8 @@ -4,6 +4,7 @@ ignore = E203 # https://github.com/PyCQA/pycodestyle/issues/373 select = B,C,E,F,P,T4,W,B9, - D417 # Missing argument descriptions in the docstring + D417, # Missing argument descriptions in the docstring + TOR # TorchFix max-line-length = 120 exclude = docs/source,third_party diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e9e64dd07d..fb071843f4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,5 +34,6 @@ repos: - id: flake8 additional_dependencies: - flake8-docstrings == 1.6.0 + - torchfix == 0.0.1 args: - --config=.flake8 From 91717150e24ae80bb250bc1fc85c05a271292262 Mon Sep 17 00:00:00 2001 From: Sergii Dymchenko Date: Mon, 12 Jun 2023 17:51:39 -0700 Subject: [PATCH 2/3] Move comments to separate lines --- .flake8 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.flake8 b/.flake8 index 25fd0e7c89..0d4b9398ff 100644 --- a/.flake8 +++ b/.flake8 @@ -1,10 +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 - TOR # TorchFix + # Missing argument descriptions in the docstring + D417, + # TorchFix + TOR max-line-length = 120 exclude = docs/source,third_party From 370019ae6d5f2406ae794c567e738c549f30c030 Mon Sep 17 00:00:00 2001 From: Sergii Dymchenko Date: Mon, 12 Jun 2023 17:52:11 -0700 Subject: [PATCH 3/3] Change assert_allclose to assert_close --- test/torchtext_unittest/data/test_jit.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/torchtext_unittest/data/test_jit.py b/test/torchtext_unittest/data/test_jit.py index 9dcb90f658..c6f33d385a 100644 --- a/test/torchtext_unittest/data/test_jit.py +++ b/test/torchtext_unittest/data/test_jit.py @@ -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 @@ -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)