Skip to content

Commit

Permalink
Update plugin code for flake8 v5 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
wwuck committed Nov 7, 2022
1 parent 045e8fe commit aac8278
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
============== ====================================


Expand Down
4 changes: 2 additions & 2 deletions doc-source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Flake8 codes

.. flake8-codes:: flake8_strftime

STRFTIME001
STRFTIME002
SFT001
SFT002



Expand Down
10 changes: 5 additions & 5 deletions flake8_strftime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@
# 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"
__license__ = "MIT"
__version__ = "0.3.1"
__email__ = "[email protected]"

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):
Expand Down Expand Up @@ -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:
Expand All @@ -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
))


Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion repo_helper.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ extra_sphinx_extensions:

entry_points:
flake8.extension:
- STRFTIME=flake8_strftime:Plugin
- SFT=flake8_strftime:Plugin

sphinx_conf_epilogue:
- nitpicky = True
Expand Down
24 changes: 12 additions & 12 deletions tests/flake8_strftime_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
}


Expand Down

0 comments on commit aac8278

Please sign in to comment.