-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
Description
Bug Report
The behavior of Final is a bit inconsistent. It can be applied post-hoc, but then it won't be honored.
To Reproduce
import platform
import sys
from typing import Final
SERIES_STD = ' ▌█' if platform.system() == 'Windows' else ' ▏▎▍▌▋▊▉█'
if sys.__stdout__ and sys.__stdout__.encoding:
try:
SERIES_STD.encode(sys.__stdout__.encoding)
except UnicodeEncodeError:
SERIES_STD = ' |'
SERIES_STD: Final = SERIES_STD
SERIES_STD = '| 'Expected Behavior
I expect an assignment error for the final line to raise an error.
error: Cannot assign to final name "SERIES_STD" [misc]Some people might argue applying Final post-hoc itself should raise an error, but I'm not one of them.
Actual Behavior
Success: no issues found in 1 source fileYour Environment
- Mypy version used: 1.18.2
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini(and other config files): No Config - Python version used: 3.13.9