8000 Clean up last traces of 'final_value' field (#6791) · python/mypy@285b683 · GitHub
[go: up one dir, main page]

Skip to content < 8000 div data-target="react-partial.reactRoot">

Commit 285b683

Browse files
Michael0x2ailevkivskyi
authored andcommitted
Clean up last traces of 'final_value' field (#6791)
This pull request is a follow-up to #6763: it renames some parameter names and variables that got missed up above. One interesting side-note: it seems like 'Var' notes also contain a `final_value` field that does almost the same thing as this `last_known_value` field, but is ultimately unrelated: it was introduced back in #5522. I decided to leave this field alone. (I discovered this while updating mypyc and discovered (to my surprise) that nothing broke.)
1 parent 56afa92 commit 285b683

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

mypy/checkexpr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,7 @@ def infer_literal_expr_type(self, value: LiteralValue, fallback_name: str) -> Ty
18041804
if self.is_literal_context():
18051805
return LiteralType(value=value, fallback=typ)
18061806
else:
1807-
return typ.copy_modified(final_value=LiteralType(
1807+
return typ.copy_modified(last_known_value=LiteralType(
18081808
value=value,
18091809
fallback=typ,
18101810
line=typ.line,

mypy/erasetype.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,5 @@ class LastKnownValueEraser(TypeTranslator):
131131

132132
def visit_instance(self, t: Instance) -> Type:
133133
if t.last_known_value:
134-
return t.copy_modified(final_value=None)
134+
return t.copy_modified(last_known_value=None)
135135
return t

mypy/newsemanal/semanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2223,7 +2223,7 @@ def analyze_simple_literal_type(self, rvalue: Expression, is_final: bool) -> Opt
22232223
assert value is not None
22242224
typ = self.named_type_or_none(type_name)
22252225
if typ and is_final:
2226-
return typ.copy_modified(final_value=LiteralType(
2226+
return typ.copy_modified(last_known_value=LiteralType(
22272227
value=value,
22282228
fallback=typ,
22292229
line=typ.line,

mypy/semanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@ def analyze_simple_literal_type(self, rvalue: Expression, is_final: bool) -> Opt
19781978
assert value is not None
19791979
typ = self.named_type_or_none(type_name)
19801980
if typ and is_final:
1981-
return typ.copy_modified(final_value=LiteralType(
1981+
return typ.copy_modified(last_known_value=LiteralType(
19821982
value=value,
19831983
fallback=typ,
19841984
line=typ.line,

mypy/type_visitor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,17 @@ def visit_deleted_type(self, t: DeletedType) -> Type:
163163
return t
164164

165165
def visit_instance(self, t: Instance) -> Type:
166-
final_value = None # type: Optional[LiteralType]
166+
last_known_value = None # type: Optional[LiteralType]
167167
if t.last_known_value is not None:
168-
raw_final_value = t.last_known_value.accept(self)
169-
assert isinstance(raw_final_value, LiteralType)
170-
final_value = raw_final_value
168+
raw_last_known_value = t.last_known_value.accept(self)
169+
assert isinstance(raw_last_known_value, LiteralType)
170+
last_known_value = raw_last_known_value
171171
return Instance(
172172
typ=t.type,
173173
args=self.translate_types(t.args),
174174
line=t.line,
175175
column=t.column,
176-
last_known_value=final_value,
176+
last_known_value=last_known_value,
177177
)
178178

179179
def visit_type_var(self, t: TypeVarType) -> Type:

mypy/types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -692,14 +692,14 @@ def deserialize(cls, data: Union[JsonDict, str]) -> 'Instance':
692692

693693
def copy_modified(self, *,
694694
args: Bogus[List[Type]] = _dummy,
695-
final_value: Bogus[Optional['LiteralType']] = _dummy) -> 'Instance':
695+
last_known_value: Bogus[Optional['LiteralType']] = _dummy) -> 'Instance':
696696
return Instance(
697697
self.type,
698698
args if args is not _dummy else self.args,
699699
self.line,
700700
self.column,
701701
self.erased,
702-
final_value if final_value is not _dummy else self.last_known_value,
702+
last_known_value if last_known_value is not _dummy else self.last_known_value,
703703
)
704704

705705
def has_readable_member(self, name: str) -> bool:

0 commit comments

Comments
 (0)
0