fix(audit): catch tokenize.TokenError, not the nonexistent TokenizeError#56
Closed
misnaej wants to merge 1 commit into
Closed
fix(audit): catch tokenize.TokenError, not the nonexistent TokenizeError#56misnaej wants to merge 1 commit into
misnaej wants to merge 1 commit into
Conversation
- tokenize has no TokenizeError — the three except clauses (claims, suppressions, dup) raised AttributeError on a tokenization failure instead of catching it - Surfaced by pyrefly; add a regression test feeding unterminated source - Bump plugin.json to 1.23.3
Owner
Author
misnaej
added a commit
that referenced
this pull request
Jun 17, 2026
- StepDef registry with --only/--skip/enable/disable overrides (closes #6) - Three opt-in steps: doctest, pyrefly typecheck, doc-consistency CLI (closes #5, #48, #4) - Config-path validation; CONFIG_KEYS drift tests (closes #46) - Fix tokenize.TokenError in audit modules; regression test (closes #56)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tokenizehas noTokenizeError— the real exception istokenize.TokenError. Three audit modules used the wrong name inexceptclauses, so a tokenization failure raisedAttributeError(the except clause itself blows up) instead of being caught and logged.Changes
audit/claims.py:321,audit/suppressions.py:286,audit/dup.py:180—TokenizeError→TokenErrortests/audit/test_dup.py— regression test: unterminated source (x = (1 +) now returns[]instead of raisingplugin.json→ 1.23.3 (patch)How it was found
pyrefly (run at strict, while dogfooding the new opt-in typecheck step from #55) flagged
[missing-attribute] No attribute TokenizeError in module tokenize. ruff doesn't check stdlib attribute existence and no test hit the failure path, so it sat latent.Testing
Full suite green; new regression test added.
Breaking Changes
None.