refactor: drop the dead initialiser in gen_utf_char - #69
Merged
cigamit merged 1 commit intoSep 13, 2026
Merged
Conversation
`b = 'b'` is never read. `is_char` starts False, so the loop below always runs at least once and rebinds `b` to the integer `chr()` is given, on every path that reaches the return. It was not harmless. It is the only reason the type checker believed `chr()` could be handed a string, reporting `Expected SupportsIndex, found Literal["b"] | int` for a call that cannot receive one. Behaviour is unchanged: 2000 draws still return a single printable character in the range the randint call specifies.
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
cigamit
approved these changes
Sep 13, 2026
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.
b = 'b'ingen_utf_charis never read.is_charstartsFalse, so the loop below always runs at least once and rebindsbto the integerchr()is given, on every path that reaches thereturn.It was not harmless. It is the only reason the type checker believed
chr()could be handed a string, reportingExpected SupportsIndex, found Literal["b"] | intfor a call that cannot receive one.tygoes from 35 diagnostics to 34.Verification
gen_utf_char()all return a single printable character within the range therandintcall specifies, so the loop's contract is unchanged.random_utf8andrandom_title(non_ascii=True), the two callers that reach it, still produce what they did.ruff format --check,ruff checkand the unit suite (366 passing) are unchanged.The
is_charsentinel is left alone. It is an ordinary loop variable rather than dead code, and rewriting the loop is a larger change than this one is.