We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d874785 commit c582e05Copy full SHA for c582e05
1 file changed
src/deadcode/cli.py
@@ -39,10 +39,16 @@ def _line_self_contained(text: str) -> bool:
39
"""
40
depth = 0
41
in_str: str | None = None
42
- prev = ""
+ escaped = False
43
for ch in text:
44
+ if escaped:
45
46
+ continue
47
+ if ch == "\\":
48
+ escaped = True
49
50
if in_str is not None:
- if ch == in_str and prev != "\\":
51
+ if ch == in_str:
52
in_str = None
53
elif ch in ("'", '"', "`"):
54
in_str = ch
@@ -52,8 +58,7 @@ def _line_self_contained(text: str) -> bool:
58
depth -= 1
59
if depth < 0: # closes something opened on an earlier line
60
return False
55
- prev = ch
56
- return depth == 0
61
+ return depth == 0 and in_str is None
57
62
63
64
@click.group()
0 commit comments