Skip to content

Commit 96931d8

Browse files
authored
Merge pull request #29 from pixelneo/attr_order
do not reorder attributes
2 parents 8e09eed + b29dc6e commit 96931d8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

python/asthelper.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ def visit_Call(self, node):
1414
class AttributeCollector(ast.NodeVisitor):
1515
def __init__(self, instance_name):
1616
self.instance_name = instance_name
17-
self.data = set()
17+
self.data = {}
1818
super().__init__()
1919

2020
def visit_Attribute(self, node):
2121
if isinstance(node.value, ast.Name):
2222
if node.value.id == self.instance_name:
23-
self.data.add(node.attr)
23+
self.data[node.attr] = None
2424
else:
2525
self.generic_visit(node)
2626

@@ -46,7 +46,7 @@ def generic_visit(self, node):
4646
class ClassVisitor(ast.NodeVisitor):
4747
def __init__(self, instance_name):
4848
super().__init__()
49-
self.attributes = set()
49+
self.attributes = {}
5050
self.instance_name = instance_name
5151

5252
def visit_Assign(self, node):

python/pydocstring.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def _process_tree(self, tree):
232232
x.visit(tree)
233233
v = ClassVisitor(x.instance_name)
234234
v.visit(tree)
235-
att = list(v.attributes)
235+
att = [attr_name for attr_name in v.attributes]
236236
return att
237237

238238
def write_docstring(self, *args, **kwargs):

0 commit comments

Comments
 (0)