8000 Constant fold initializers of final variables by JukkaL · Pull Request #14283 · python/mypy · GitHub
[go: up one dir, main page]

Skip to content

Constant fold initializers of final variables #14283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Dec 15, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Disable final value calculation in enum classes
  • Loading branch information
JukkaL committed Dec 10, 2022
commit 92f25b9f2d44f2cc8278ba006a1f536f80c8c8a2
2 changes: 1 addition & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -3819,7 +3819,7 @@ def store_declared_types(self, lvalue: Lvalue, typ: Type) -> None:
var.type = typ
var.is_ready = True
typ = get_proper_type(typ)
if var.is_final and isinstance(typ, Instance) and typ.last_known_value:
if var.is_final and isinstance(typ, Instance) and typ.last_known_value and (not self.type or not self.type.is_enum):
var.final_value = typ.last_known_value.value
# If node is not a variable, we'll catch it elsewhere.
elif isinstance(lvalue, TupleExpr):
Expand Down
0