qualifiers_final_annotation_2
error
Final type qualifier annotation violations
Detects violations of PEP 591's rules for the Final qualifier, beyond the positional errors handled by E0044. Specifically:
1. **Class attribute Final without init** — ID2: Final / ID3: Finalint in a class body without an initializer and not assigned in __init__.
2. **Instance Final outside __init__** — self.id3: Final = 1 in a method other than __init__.
3. **Re-assignment to already-initialized Final** — self.ID5 = 0 when ID5: Finalint = 0 is already given a value in the class body.
4. **Modification of Final class attribute** — self.ID7 = 0 / self.ID7 += 1 when ID7 is declared Final in the class body.
5. **Module-level Final re-assignment** — RATE = 300 after RATE: Final = 3000.
6. **Class attribute re-assignment** — ClassB.DEFAULT_ID = 0 when DEFAULT_ID is declared Final in ClassB.
7. **Subclass override of Final** — BORDER_WIDTH = 2.5 in a subclass when the parent declares BORDER_WIDTH: Final = 2.5.
8. **Function-local Final modification** — x += 1 when x: Final = 3, or walrus/for/with/tuple-unpack on a Final variable.
9. **Global Final modification** — global ID1; ID1 = 2 inside a function when ID1 is a module-level Final.
How to handle it
Every rule is on by default — strict is the default, not a cage. You can dial
qualifiers_final_annotation_2 down per-file or per-path from your editor or
pyproject.toml, or fix the code
so it type-checks. See the Type System rules and
the complete diagnostic reference.
Canonical URL: https://www.basilisk-python.dev/errors/qualifiers_final_annotation_2