From aac8278d056061f797f41a09a798771c24791e60 Mon Sep 17 00:00:00 2001 From: wwuck Date: Mon, 7 Nov 2022 15:33:11 +1100 Subject: [PATCH] Update plugin code for flake8 v5 compatibility Fixes #47 --- README.rst | 10 +++++----- doc-source/usage.rst | 4 ++-- flake8_strftime/__init__.py | 10 +++++----- pyproject.toml | 2 +- repo_helper.yml | 2 +- tests/flake8_strftime_test.py | 24 ++++++++++++------------ 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/README.rst b/README.rst index 941b5f4..9a455bf 100644 --- a/README.rst +++ b/README.rst @@ -153,11 +153,11 @@ To install with ``conda``: flake8 codes -------------- -============== ==================================== -Code Description -============== ==================================== -STRFTIME001 Linux-specific strftime code used -STRFTIME002 Windows-specific strftime code used +========= ==================================== +Code Description +========= ==================================== +SFT001 Linux-specific strftime code used +SFT002 Windows-specific strftime code used ============== ==================================== diff --git a/doc-source/usage.rst b/doc-source/usage.rst index 4ad6bdb..40c92de 100644 --- a/doc-source/usage.rst +++ b/doc-source/usage.rst @@ -10,8 +10,8 @@ Flake8 codes .. flake8-codes:: flake8_strftime - STRFTIME001 - STRFTIME002 + SFT001 + SFT002 diff --git a/flake8_strftime/__init__.py b/flake8_strftime/__init__.py index 50a3694..60fef68 100644 --- a/flake8_strftime/__init__.py +++ b/flake8_strftime/__init__.py @@ -40,7 +40,7 @@ # 3rd party import flake8_helper -__all__ = ("Visitor", "Plugin", "STRFTIME001", "STRFTIME002") +__all__ = ("Visitor", "Plugin", "SFT001", "SFT002") __author__ = "Dominic Davis-Foster" __copyright__ = "2020-2021 Dominic Davis-Foster" @@ -48,8 +48,8 @@ __version__ = "0.3.1" __email__ = "dominic@davis-foster.co.uk" -STRFTIME001 = "STRFTIME001 Linux-specific strftime code used." -STRFTIME002 = "STRFTIME002 Windows-specific strftime code used." +SFT001 = "SFT001 Linux-specific strftime code used." +SFT002 = "SFT002 Windows-specific strftime code used." class Visitor(flake8_helper.Visitor): @@ -102,7 +102,7 @@ def _check_linux(self, node: Union[ast.Str, ast.Constant]) -> None: self.errors.append(( node.lineno, node.col_offset + match.span()[0], - STRFTIME001, # pylint: disable=loop-global-usage + SFT001, # pylint: disable=loop-global-usage )) def _check_windows(self, node: Union[ast.Str, ast.Constant]) -> None: @@ -116,7 +116,7 @@ def _check_windows(self, node: Union[ast.Str, ast.Constant]) -> None: self.errors.append(( node.lineno, node.col_offset + match.span()[0], - STRFTIME002, # pylint: disable=loop-global-usage + SFT002, # pylint: disable=loop-global-usage )) diff --git a/pyproject.toml b/pyproject.toml index e390f2a..a3a8e5f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -136,7 +136,7 @@ show_error_codes = true directives = [ "code-block",] [project.entry-points."flake8.extension"] -STRFTIME = "flake8_strftime:Plugin" +SFT = "flake8_strftime:Plugin" [tool.dependency-dash."requirements.txt"] order = 10 diff --git a/repo_helper.yml b/repo_helper.yml index d88a3fb..58f7593 100644 --- a/repo_helper.yml +++ b/repo_helper.yml @@ -48,7 +48,7 @@ extra_sphinx_extensions: entry_points: flake8.extension: - - STRFTIME=flake8_strftime:Plugin + - SFT=flake8_strftime:Plugin sphinx_conf_epilogue: - nitpicky = True diff --git a/tests/flake8_strftime_test.py b/tests/flake8_strftime_test.py index 020dde1..bfe547d 100644 --- a/tests/flake8_strftime_test.py +++ b/tests/flake8_strftime_test.py @@ -14,26 +14,26 @@ def results(s: str) -> Set[str]: def test_linux_specific(): - assert results('print(f"{now:%Y/%-m/%-d %H:%M}")') == { # noqa: STRFTIME001 - "1:9: STRFTIME001 Linux-specific strftime code used.", - "1:13: STRFTIME001 Linux-specific strftime code used.", + assert results('print(f"{now:%Y/%-m/%-d %H:%M}")') == { # noqa: SFT001 + "1:9: SFT001 Linux-specific strftime code used.", + "1:13: SFT001 Linux-specific strftime code used.", } - assert results('print(now.strftime("%Y/%-m/%-d %H:%M"))') == { # noqa: STRFTIME001 - "1:22: STRFTIME001 Linux-specific strftime code used.", - "1:26: STRFTIME001 Linux-specific strftime code used.", + assert results('print(now.strftime("%Y/%-m/%-d %H:%M"))') == { # noqa: SFT001 + "1:22: SFT001 Linux-specific strftime code used.", + "1:26: SFT001 Linux-specific strftime code used.", } def test_windows_specific(): - assert results('print(f"{now:%Y/%#m/%#d %H:%M}")') == { # noqa: STRFTIME002 - "1:9: STRFTIME002 Windows-specific strftime code used.", - "1:13: STRFTIME002 Windows-specific strftime code used.", + assert results('print(f"{now:%Y/%#m/%#d %H:%M}")') == { # noqa: SFT002 + "1:9: SFT002 Windows-specific strftime code used.", + "1:13: SFT002 Windows-specific strftime code used.", } - assert results('print(now.strftime("%Y/%#m/%#d %H:%M"))') == { # noqa: STRFTIME002 - "1:22: STRFTIME002 Windows-specific strftime code used.", - "1:26: STRFTIME002 Windows-specific strftime code used.", + assert results('print(now.strftime("%Y/%#m/%#d %H:%M"))') == { # noqa: SFT002 + "1:22: SFT002 Windows-specific strftime code used.", + "1:26: SFT002 Windows-specific strftime code used.", }