Skip to content

Commit 762a755

Browse files
committed
Fix CI
1 parent 517beb1 commit 762a755

3 files changed

Lines changed: 8 additions & 10 deletions

File tree

mypyc/irbuild/classdef.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -764,11 +764,9 @@ def find_attr_initializers(
764764
if info_ir is None:
765765
continue
766766
for stmt in info.defn.defs.body:
767-
if (
768-
isinstance(stmt, AssignmentStmt)
769-
and isinstance(stmt.lvalues[0], NameExpr)
770-
and stmt.lvalues[0].name == "__deletable__"
771-
):
767+
if not isinstance(stmt, AssignmentStmt):
768+
continue
769+
if isinstance(stmt.lvalues[0], NameExpr) and stmt.lvalues[0].name == "__deletable__":
772770
check_deletable_declaration(builder, cls, stmt.line)
773771
continue
774772
name = default_attr_name(stmt, info_ir, cls_type)

mypyc/irbuild/prepare.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from mypy.nodes import (
2222
ARG_STAR,
2323
ARG_STAR2,
24+
AssignmentStmt,
2425
CallExpr,
2526
ClassDef,
2627
Decorator,
@@ -432,7 +433,9 @@ def _has_own_default_attrs(cdef: ClassDef, ir: ClassIR) -> bool:
432433
return False
433434
cls_type = dataclass_type(cdef)
434435
return any(
435-
default_attr_name(stmt, ir, cls_type) is not None for stmt in cdef.info.defn.defs.body
436+
default_attr_name(stmt, ir, cls_type) is not None
437+
for stmt in cdef.info.defn.defs.body
438+
if isinstance(stmt, AssignmentStmt)
436439
)
437440

438441

mypyc/irbuild/util.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
NameExpr,
2525
OverloadedFuncDef,
2626
RefExpr,
27-
Statement,
2827
StrExpr,
2928
TempNode,
3029
TupleExpr,
@@ -123,16 +122,14 @@ def defaults_skip(stmt: AssignmentStmt, cls_type: str | None) -> bool:
123122
return False
124123

125124

126-
def default_attr_name(stmt: Statement, ir: ClassIR, cls_type: str | None) -> str | None:
125+
def default_attr_name(stmt: AssignmentStmt, ir: ClassIR, cls_type: str | None) -> str | None:
127126
"""Return the attribute name if `stmt` is a class-level default assignment
128127
that __mypyc_defaults_setup should emit; otherwise None.
129128
130129
Single source of truth for the predicate used by both
131130
mypyc.irbuild.classdef.find_attr_initializers (IR build) and
132131
mypyc.irbuild.prepare._has_own_default_attrs (prepare-phase decl registration).
133132
"""
134-
if not isinstance(stmt, AssignmentStmt):
135-
return None
136133
lvalue = stmt.lvalues[0]
137134
if not isinstance(lvalue, NameExpr) or is_class_var(lvalue):
138135
return None

0 commit comments

Comments
 (0)