Changed semantics of ClassVar attributes in classes, fixes #1502

This commit is contained in:
Dave Halter
2020-03-13 12:53:05 +01:00
parent b4fa42a282
commit 521e240c5f
2 changed files with 8 additions and 4 deletions

View File

@@ -115,7 +115,11 @@ class ClassFilter(ParserTreeFilter):
annassign = expr_stmt.children[1]
if annassign.type == 'annassign':
# TODO this is not proper matching
if 'ClassVar' not in annassign.children[1].get_code():
# If there is an =, the variable is obviously also
# defined on the class.
if 'ClassVar' not in annassign.children[1].get_code() \
and '=' not in annassign.children:
return False
# Filter for name mangling of private variables like __foo