Let's say I have:
- Package A that we will call
BaseObjectsin what follows - Project B that installs
BaseObjectsas a dependency and defines subclasses for some classes defined inBaseOjects - Project C that installs
BaseObjectsas a dependency but does not have access in any way to Project B
Let's call one of the classes defined in BaseObjects: Point. Another class is called Line that takes as attributes 2 Point instances p1 and p2.
Package B implements a class PointB(Point). The objects PointB are therefore also instances of BaseObjects.Point.
While in an environment related to Project B, I create an object Line that uses 2 PointB objects. I do all sort of operations with the special methods that PointB implements.
I now want to pickle this Line object so that it can be loaded in Project C. To that purpose, I cannot keep the PointB instances. I therefore need to "reclass" them to be of the type of the superclass only. I do p1.__class__ = Point and p2.__class__ = Point. I check that: isinstance(p1, PointB) evaluates to False, same for p2.
Therefore, I thought that the object pickled this way will be readable from Project C as it has the dependency to BaseObjects which defines the class Point.
It isn't the case. When I load the pickle file in Project C, it looks for the folder in which I defined the subclasses in Project B. However, as I dig through the object, I do not find any link. All the objects are said to be of type BaseObjects.<class_name>
What's wrong in my process of getting rid of this object's dependency to Project B? Is there a way to see all the dependencies of an object?