XPlane2Blender
XPlane2Blender copied to clipboard
Remove relative imports and circular dependencies, make XP2B fully reloadable
As we start adding typing hints (see #322) to XPlane2Blender for documentation and static type checking purposes, we'll need to start annotating the code.
One issue is that some objects have created circular dependencies which get activated when referencing the type.
For instance, attempting to annotate xplaneFile=None
as ``xplaneFile:Optional[io_xplane2blender.xplane_types.xplane_file.XPlaneFile]=None in XPlaneBone's constructor causes a circular import because XPlaneFile imports XPlaneBone!
To make matters worse, xplane_type's init.py script imports a bunch of XPlaneTypes (now out of date) for no reason. The only of instance of
from.*xplane_types import Something
was in test.py, line 14 to import XPlanePrimative
Given that this is not a package or an API for public consumption, I think we can chose to prioritize explicitness over convenience and have a blank xplane_types/init.py, and stop using relative imports.
Having to constantly restart Blender to test code changes is a drag. A previous attempt at making the reloading of classes was an unorganized "investigation" rather than a real effort.
Here are some links that can help start this process. I think solving this will be good in tandem with #338, due to needing to remove complex from ... import ... imports (I think)
Blender Specific
Python Docs
StackOverflow
- How Do I Reload A Module After Changing It
- importlib.reload does not reload programmatically generated file
This may be something that can be done incrementally. Maybe.
This may be helpful information: https://developer.blender.org/T67387#982929
More talk at https://developer.blender.org/T66924