Commit 09f3f74
committed
Fix mypy error: cast_unicode annotation exposes None passed from tbtools
cast_unicode was annotated as accepting str | bytes, but tbtools.py
_tokens_filename passes file: str | None to it without a None guard.
This would crash at runtime if file is None since cast_unicode passes
the value through to compress_user which calls .startswith() on it.
Fix: add `file or ""` guard at the tbtools.py call site, which is the
correct behaviour (treat a missing filename as an empty string).
The annotation cast_unicode(s: str | bytes) -> str is correct.
https://claude.ai/code/session_01L2i6WEqHEX3HyCMWgimmEp1 parent b580127 commit 09f3f74
2 files changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
203 | 203 | | |
204 | 204 | | |
205 | 205 | | |
206 | | - | |
| 206 | + | |
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | | - | |
| 24 | + | |
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| |||
0 commit comments