Skip to content

Commit 12c2fdf

Browse files
committed
fix(parser): This commit fixes missing attr when default set
1 parent d30da50 commit 12c2fdf

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

codetide/parsers/python_parser.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,16 +294,20 @@ def _process_assignment(cls, node: Node, code: bytes, codeFile: CodeFileModel, i
294294
type_hint = None
295295
default = None
296296
next_is_default = None
297+
previous_child = None
297298
for child in node.children:
298299
if child.type == "identifier" and attribute is None:
299300
attribute = cls._get_content(code, child)
300301
elif child.type == "type":
301302
type_hint = cls._get_content(code, child)
302303
elif child.type == "=" and next_is_default is None:
303304
next_is_default = True
305+
if attribute is None and previous_child:
306+
attribute = cls._get_content(code, previous_child)
304307
elif default is None and next_is_default:
305308
default = cls._get_content(code, child)
306309
next_is_default = None
310+
previous_child = child
307311

308312
if is_class_attribute:
309313
raw = cls._get_content(code, node, preserve_indentation=True)

0 commit comments

Comments
 (0)