Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "forge",
"version": "1.23.2",
"version": "1.23.3",
"description": "Automate Python CI/CD and code-quality standards — deterministic CLIs + a drop-in pre-commit hook, runnable with or without an AI agent. This optional Claude Code plugin orchestrates them; the gate is the CLI, never the model.",
"author": {
"name": "Jean Simonnet",
Expand Down
2 changes: 1 addition & 1 deletion src/forge/audit/claims.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def _comment_findings(
evidence=(comment_body[:COMMENT_PREVIEW],),
),
)
except tokenize.TokenizeError as exc:
except tokenize.TokenError as exc:
logger.debug("tokenize failed in %s: %s", rel, exc)
return findings

Expand Down
2 changes: 1 addition & 1 deletion src/forge/audit/dup.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def _tokenize_body(source: str) -> list[str]:
tokens.append(tok.string if keyword.iskeyword(tok.string) else "ID")
else:
tokens.append(tok.string)
except tokenize.TokenizeError:
except tokenize.TokenError:
logger.debug("tokenize failed on a snippet — skipping")
return []
return tokens
Expand Down
2 changes: 1 addition & 1 deletion src/forge/audit/suppressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def _iter_comments(text: str) -> list[tuple[int, str]]:
seen_lines.add(line_no)
if 1 <= line_no <= len(source_lines):
pairs.append((line_no, source_lines[line_no - 1]))
except tokenize.TokenizeError as exc:
except tokenize.TokenError as exc:
logger.debug("tokenize failed: %s", exc)
return pairs

Expand Down
12 changes: 12 additions & 0 deletions tests/audit/test_dup.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ def test_tokenize_body_collapses_strings_and_numbers() -> None:
assert "42" not in tokens


def test_tokenize_body_returns_empty_on_token_error() -> None:
"""Unterminated source is swallowed and yields ``[]``, not an exception.

Regression: the handler caught ``tokenize.TokenizeError`` — a name that
does not exist in the stdlib (the real exception is
``tokenize.TokenError``) — so a tokenization failure raised
``AttributeError`` instead of being caught. The unclosed parenthesis
below makes ``tokenize`` raise ``TokenError`` at EOF.
"""
assert _tokenize_body("x = (1 +") == []


def test_shingles_returns_empty_when_shorter_than_k() -> None:
"""A token sequence below ``k`` length yields no shingles."""
assert _shingles(["a", "b"], k=5) == frozenset()
Expand Down
Loading