pylint-bot / test

0 stars 0 forks source link

Lots of circular dependencies in the project #147

Closed pylint-bot closed 8 years ago

pylint-bot commented 9 years ago

Originally reported by: Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore?)


The current state of the project is far from being good, mostly due to circular dependencies between a lot of components, which leads to low reusability and ugly design hacks:


pylint-bot commented 8 years ago

Original comment by Claudiu Popa (BitBucket: PCManticore, GitHub: @PCManticore?):


Most of the circular dependencies are fixed in bookmark 2.0. The idea through this get fixed was to use virtual base classes for nodes and other objects, which means that object needs to register itself as a concrete implementation of one or more virtual base classes. This means that isinstance can be used with virtual base classes now, rather than with concrete objects, which removed almost all the dependencies we had in the project. Another pain was the use of monkey patching in inference.py and protocols.py, which is now removed by implementing dispatch methods on virtual base classes instead. There were some places though where we needed the concrete node classes in order to build nodes during inference, which is solved with dependency injection: in node_classes, when these functions are called, we pass the current module as an extra argument.

Solving this issue also meant the separation of nodes from runtime objects, which now live in two separate namespaces, astroid.tree respectively astroid.interpreter.