Skip to content

Commit

Permalink
Fix check for python 3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
10sr committed Oct 18, 2023
1 parent 7de98d1 commit 5a37b4c
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion flake8_no_implicit_concat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,27 @@
}


def _is_ok_lt_py312(a: tokenize.TokenInfo, b: tokenize.TokenInfo) -> bool:
return not a.type == b.type == tokenize.STRING


def _is_ok(a: tokenize.TokenInfo, b: tokenize.TokenInfo) -> bool:
if a.type == b.type == tokenize.STRING:
return False
if a.type == tokenize.STRING and b.type == tokenize.FSTRING_START: # type: ignore[attr-defined]
return False
if a.type == tokenize.FSTRING_END and b.type == tokenize.STRING: # type: ignore[attr-defined]
return False
if a.type == tokenize.FSTRING_END and b.type == tokenize.FSTRING_START: # type: ignore[attr-defined]
return False
return True


if sys.version_info < (3, 12): # pragma: no cover
# E811 redefinition of unused '_is_ok' from line 36
_is_ok = _is_ok_lt_py312 # noqa


def _check(tokens: Iterable[tokenize.TokenInfo]) -> Iterable[_ERROR]:
tokens_wo_ws = (
e
Expand All @@ -43,7 +64,7 @@ def _check(tokens: Iterable[tokenize.TokenInfo]) -> Iterable[_ERROR]:
)
)
for a, b in pairwise(tokens_wo_ws):
if not (a.type == b.type == tokenize.STRING):
if _is_ok(a, b):
continue

on_one_line = a.end[0] == b.start[0]
Expand Down

0 comments on commit 5a37b4c

Please sign in to comment.