No project description provided
Project description
auto-typing-final
Auto-fixer for Python code that adds typing.Final
annotation to variable assignments inside functions that are not reassigned, and removes the annotation from variables that are mutated.
Keeps mypy happy.
- Global
import typing
will be added iftyping
was not imported before. - Global variables are ignored to avoid confusion with the type aliases like
Fruit = Apple | Banana
. - Class variables are ignored since it is common to use
typing.ClassVar
instead oftyping.Final
. - One file at a time is inspected.
How To Use
uv tool run auto-typing-final .
or:
pipx run auto-typing-final .
You can specify --check
flag to check the files instead of actually fixing them:
auto-typing-final . --check
VS Code key binding
Add to your keybindings.json
:
{
"key": "ctrl+shift+t",
"when": "editorLangId == 'python'",
"command": "runCommands",
"args": {
"commands": [
"workbench.action.files.save",
"workbench.action.terminal.newInActiveWorkspace",
"workbench.action.terminal.toggleTerminal",
{
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "uv tool run auto-typing-final ${file}\u000Dexit\u000D"
}
}
]
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for auto_typing_final-0.3.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5487dae871c5faeb1f89ce6ce43b8bfd9b76bd591c5db5cdec6a2a383fd7ad6e |
|
MD5 | a7824896e830d107c6abbb6291d6564d |
|
BLAKE2b-256 | 87611eb309324cb5b1c4f5a61ef5842ad808341605dcae917d84e1fec379d290 |