logilab-astng #18773 inference bug on class members [validation pending]
Now to the issue at hand: Running pylint 0.18.1 (with Python 2.5.4, logilab_astng-0.19.1 and logilab_common-0.44.0) for the attached test.py generates following error (E1101 I believe): E: 37:DataManager.TestFunc: Instance of 'DataManager' has no 'project' member This message is generated for the last line of the following snippet: class DataManager(object): def __init__(self): self.app = get_active_application() def TestFunc(self): app = self.app print app.project As you can see, it incorrectly reports app as DataManager instance (it is be Application instance instead - see the attached file). Also, Application class in fact has a 'project' member variable. Code itself has commented-out demonstration how to work around this error message - essentially it comprises of not using global function to acquire the Application instance. active_application = None def get_active_application(): global active_application return active_application class Application(object): def __init__(self): global active_application active_application = self self.project = None class Project(object): def __init__(self): pass class DataManager(object): def __init__(self, app=None): # # This causes error to be generated. Using "self.app = app" # instead will not. # self.app = get_active_application() #self.app = app print app # Suppress possible unused variable warning def TestFunc(self): app = self.app print app.project def main(): app = Application() app.project = Project() data_manager = DataManager(app) data_manager.TestFunc() main() | |
priority | normal |
---|---|
type | bug |
done in | 0.19.2 |
load | 0.500 |
load left | 0.000 |
closed by | <not specified> |
similar entities