Skip to content

Commit 19697af

Browse files
fix: something Shantanu found (#19859)
to be honest I have no idea what this code does, but I know we need to fix it per advice from @hauntsaninja in #19846
1 parent a936e30 commit 19697af

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

mypy/strconv.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,9 @@ def visit_name_expr(self, o: mypy.nodes.NameExpr) -> str:
388388
o.name, o.kind, o.fullname, o.is_inferred_def or o.is_special_form, o.node
389389
)
390390
if isinstance(o.node, mypy.nodes.Var) and o.node.is_final:
391-
pretty += f" = {o.node.final_value}"
391+
final_value = o.node.final_value
392+
if final_value is not None:
393+
pretty += f" = {o.node.final_value}"
392394
return short_type(o) + "(" + pretty + ")"
393395

394396
def pretty_name(

test-data/unit/semanal-basic.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ MypyFile:1(
521521
NameExpr(True [builtins.True])
522522
Literal[True]?)
523523
AssignmentStmt:8(
524-
NameExpr(n* [__main__.n] = None)
524+
NameExpr(n* [__main__.n])
525525
CallExpr:8(
526526
NameExpr(func [__main__.func])
527527
Args())))

0 commit comments

Comments
 (0)