XPlane2Blender icon indicating copy to clipboard operation
XPlane2Blender copied to clipboard

Remove relative imports and circular dependencies, make XP2B fully reloadable

Open tngreene opened this issue 6 years ago • 3 comments

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.

tngreene avatar Mar 14 '18 18:03 tngreene

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

This may be something that can be done incrementally. Maybe.

tngreene avatar Apr 23 '18 19:04 tngreene

This may be helpful information: https://developer.blender.org/T67387#982929

tngreene avatar Jul 21 '20 18:07 tngreene

More talk at https://developer.blender.org/T66924

tngreene avatar Oct 27 '20 22:10 tngreene