Skip to content

Commit 41aeae0

Browse files
committed
Solve shadowing issue
1 parent 68ceb33 commit 41aeae0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

pylasu/model/model.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,15 @@ def process_annotated_property(cl: type, name: str, decl_type):
133133
fields = dataclasses.fields(cl)
134134
except TypeError:
135135
fields = tuple()
136-
for field in fields:
137-
if field.name == name and PYLASU_FEATURE in field.metadata:
138-
feature = field.metadata[PYLASU_FEATURE]
136+
# We do not name it field to avoid shadowing the imported field
137+
for local_field in fields:
138+
if local_field.name == name and PYLASU_FEATURE in local_field.metadata:
139+
feature = local_field.metadata[PYLASU_FEATURE]
139140
feature.name = name
140141
if isinstance(decl_type, type):
141142
feature.type = decl_type
142-
elif type(field.type) is str:
143-
feature.type = try_to_resolve_string_type(field.type, name, cl)
143+
elif type(local_field.type) is str:
144+
feature.type = try_to_resolve_string_type(local_field.type, name, cl)
144145
return feature
145146
return compute_feature_from_annotation(cl, name, decl_type)
146147

0 commit comments

Comments
 (0)