Skip to content

Commit da81f1f

Browse files
committed
refactor: Remove self class from scope
This will remove "Foo = serde_scope.types["Foo"]" from the function generated for Foo. ``` def from_dict(data, reuse_instances=True): if reuse_instances is Ellipsis: reuse_instances = True Foo = serde_scope.types["Foo"] ... ```
1 parent cc16cb0 commit da81f1f

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

serde/de.py

+3
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ def wrap(cls: Type):
122122

123123
# Collect types used in the generated code.
124124
for typ in iter_types(cls):
125+
if typ is cls:
126+
continue
127+
125128
if is_dataclass(typ) or is_enum(typ) or not is_primitive(typ):
126129
scope.types[typ.__name__] = typ
127130

serde/se.py

+3
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ def wrap(cls: Type):
133133

134134
# Collect types used in the generated code.
135135
for typ in iter_types(cls):
136+
if typ is cls:
137+
continue
138+
136139
if is_dataclass(typ) or is_enum(typ) or not is_primitive(typ):
137140
scope.types[typ.__name__] = typ
138141

0 commit comments

Comments
 (0)