Bug when a variable names appear as temporary in a for while defining the outer list
Closed this issue · 2 comments
AntonioCheca commented
This code:
def f(parentObject):
return [parentObject.b for parentObject in parentObject.c]
class ChildExampleClass:
def __init__(self, someInteger):
self.b = someInteger
class ParentExampleClass:
def __init__(self):
self.c = [ChildExampleClass(1), ChildExampleClass(2)]
parentEx = ParentExampleClass()
print(f(parentEx))
outputs [1,2]
It gets minified to:
def f(parentObject):return[A.b for A in A.c]
class ChildExampleClass:
def __init__(A,someInteger):A.b=someInteger
class ParentExampleClass:
def __init__(A):A.c=[ChildExampleClass(1),ChildExampleClass(2)]
parentEx=ParentExampleClass()
print(f(parentEx))
Notice how now f isn't well defined, and it will complain that A is not defined.
I'm aware this code is against multiple clean code practices.
dflook commented
Hello @AntonioCheca, thanks for creating an issue. This is fixed in 2.8.1
AntonioCheca commented
Hello @dflook , thank you very much! Closing the issue then