Skip to content

Commit 1766638

Browse files
authored
Merge pull request #109 from dflook/fix-class-annotation-namespace
Fix namespace for new Assign nodes introduced by annotation removal.
2 parents 3daead3 + eb72d47 commit 1766638

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

corpus_test/generate_results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def corpus_test(corpus_path, results_path, sha, regenerate_results):
115115
if entry in result_writer:
116116
continue
117117

118-
logging.debug(entry)
118+
logging.debug('Corpus entry [' + entry + ']')
119119

120120
result = minify_corpus_entry(corpus_path, entry)
121121
result_writer.write(result)

src/python_minifier/transforms/remove_annotations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,11 @@ def is_typing_sensitive(node):
120120
if is_dataclass_field(node) or is_typing_sensitive(node):
121121
return node
122122
elif node.value:
123-
return self.add_child(ast.Assign([node.target], node.value), parent=node.parent)
123+
return self.add_child(ast.Assign([node.target], node.value), parent=node.parent, namespace=node.namespace)
124124
else:
125125
# Valueless annotations cause the interpreter to treat the variable as a local.
126126
# I don't know of another way to do that without assigning to it, so
127127
# keep it as an AnnAssign, but replace the annotation with '0'
128128

129-
node.annotation = self.add_child(ast.Num(0), parent=node.parent)
129+
node.annotation = self.add_child(ast.Num(0), parent=node.parent, namespace=node.namespace)
130130
return node

0 commit comments

Comments
 (0)