From eefecdea2a9924692099d576636dc3bb36d12b4f Mon Sep 17 00:00:00 2001 From: Jirka Date: Sat, 25 Sep 2021 00:34:22 +0200 Subject: [PATCH 1/4] apply yesqa Signed-off-by: Jirka --- .pre-commit-config.yaml | 10 +++++----- docs/source/conf.py | 2 +- monai/__init__.py | 2 +- monai/utils/aliases.py | 2 +- tests/runner.py | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 71f9ac71ef..faa16999c4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -34,11 +34,11 @@ repos: monai/_version.py )$ - #- repo: https://github.com/asottile/yesqa - # rev: v1.2.3 - # hooks: - # - id: yesqa - # name: Unused noqa + - repo: https://github.com/asottile/yesqa + rev: v1.2.3 + hooks: + - id: yesqa + name: Unused noqa #- repo: https://github.com/PyCQA/isort # rev: 5.9.3 diff --git a/docs/source/conf.py b/docs/source/conf.py index 324be8a0fd..46c905f99c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -18,7 +18,7 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))) print(sys.path) -import monai # noqa: E402 +import monai # -- Project information ----------------------------------------------------- project = "MONAI" diff --git a/monai/__init__.py b/monai/__init__.py index 2c7c920162..7ab30bcae7 100644 --- a/monai/__init__.py +++ b/monai/__init__.py @@ -33,7 +33,7 @@ ), ) -from .utils.module import load_submodules # noqa: E402 +from .utils.module import load_submodules # handlers_* have some external decorators the users may not have installed # *.so files and folder "_C" may not exist when the cpp extensions are not compiled diff --git a/monai/utils/aliases.py b/monai/utils/aliases.py index a08dab4f95..cae73d35b4 100644 --- a/monai/utils/aliases.py +++ b/monai/utils/aliases.py @@ -80,7 +80,7 @@ def resolve_name(name): if obj is None: # Get all modules having the declaration/import, need to check here that getattr returns something which doesn't # equate to False since in places __getattr__ returns 0 incorrectly: - # https://github.com/tensorflow/tensorboard/blob/a22566561d2b4fea408755a951ac9eaf3a156f8e/tensorboard/compat/tensorflow_stub/pywrap_tensorflow.py#L35 # noqa: B950 + # https://github.com/tensorflow/tensorboard/blob/a22566561d2b4fea408755a951ac9eaf3a156f8e/tensorboard/compat/tensorflow_stub/pywrap_tensorflow.py#L35 mods = [m for m in list(sys.modules.values()) if getattr(m, name, None)] if len(mods) > 0: # found modules with this declaration or import diff --git a/tests/runner.py b/tests/runner.py index b340d60719..0d72196b0b 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -30,14 +30,14 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.timed_tests = {} - def startTest(self, test): # noqa: N802 + def startTest(self, test): """Start timer, print test name, do normal test.""" self.start_time = time.time() name = self.getDescription(test) self.stream.write(f"Starting test: {name}...\n") super().startTest(test) - def stopTest(self, test): # noqa: N802 + def stopTest(self, test): """On test end, get time, print, store and do normal behaviour.""" elapsed = time.time() - self.start_time name = self.getDescription(test) From 8ba78a213774cdd466968c5bac8060f501ca9443 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 30 Sep 2021 15:05:29 +0200 Subject: [PATCH 2/4] rev Signed-off-by: Jirka --- tests/runner.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/runner.py b/tests/runner.py index 0d72196b0b..b340d60719 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -30,14 +30,14 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.timed_tests = {} - def startTest(self, test): + def startTest(self, test): # noqa: N802 """Start timer, print test name, do normal test.""" self.start_time = time.time() name = self.getDescription(test) self.stream.write(f"Starting test: {name}...\n") super().startTest(test) - def stopTest(self, test): + def stopTest(self, test): # noqa: N802 """On test end, get time, print, store and do normal behaviour.""" elapsed = time.time() - self.start_time name = self.getDescription(test) From 60aa5529dcbf729a50d2639554ae7f81b65ce8a9 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 30 Sep 2021 15:15:27 +0200 Subject: [PATCH 3/4] expand Signed-off-by: Jirka --- setup.cfg | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/setup.cfg b/setup.cfg index 309169ebe8..19f04de526 100644 --- a/setup.cfg +++ b/setup.cfg @@ -83,9 +83,22 @@ max_line_length = 120 # C408 ignored because we like the dict keyword argument syntax # E501 is not flexible enough, we're using B950 instead ignore = - E203,E305,E402,E501,E721,E741,F821,F841,F999,W503,W504,C408,E302,W291,E303, - # N812 lowercase 'torch.nn.functional' imported as non lowercase 'F' - N812 + E203 + E305 + E402 + E501 + E721 + E741 + F821 + F841 + F999 + W503 + W504 + C408 + E302 + W291 + E303 + N812 # lowercase 'torch.nn.functional' imported as non lowercase 'F' per_file_ignores = __init__.py: F401 exclude = *.pyi,.git,.eggs,monai/_version.py,versioneer.py,venv,.venv,_version.py From b1097055b057374a17a0f5e4e64844ca37d3c584 Mon Sep 17 00:00:00 2001 From: Jirka Date: Thu, 30 Sep 2021 16:50:03 +0200 Subject: [PATCH 4/4] plugins Signed-off-by: Jirka --- .pre-commit-config.yaml | 7 +++++++ monai/utils/aliases.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index faa16999c4..980a562610 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,6 +39,13 @@ repos: hooks: - id: yesqa name: Unused noqa + additional_dependencies: + - flake8>=3.8.1 + - flake8-bugbear + - flake8-comprehensions + - flake8-executable + - flake8-pyi + - pep8-naming #- repo: https://github.com/PyCQA/isort # rev: 5.9.3 diff --git a/monai/utils/aliases.py b/monai/utils/aliases.py index cae73d35b4..a08dab4f95 100644 --- a/monai/utils/aliases.py +++ b/monai/utils/aliases.py @@ -80,7 +80,7 @@ def resolve_name(name): if obj is None: # Get all modules having the declaration/import, need to check here that getattr returns something which doesn't # equate to False since in places __getattr__ returns 0 incorrectly: - # https://github.com/tensorflow/tensorboard/blob/a22566561d2b4fea408755a951ac9eaf3a156f8e/tensorboard/compat/tensorflow_stub/pywrap_tensorflow.py#L35 + # https://github.com/tensorflow/tensorboard/blob/a22566561d2b4fea408755a951ac9eaf3a156f8e/tensorboard/compat/tensorflow_stub/pywrap_tensorflow.py#L35 # noqa: B950 mods = [m for m in list(sys.modules.values()) if getattr(m, name, None)] if len(mods) > 0: # found modules with this declaration or import