class pluginAAlias.PluginAAlias
class pluginAAlias.PluginAAlias
False
Huh??!!! I then expanded the print statements to print the id() of the classes, and sure enough the id’s were different – so that was why isinstance was failing, and super() was raising the TypeError.
With a little more instrumenting, I found that our code for loading the plugin modules can get run repeatedly. And this was the final piece of the puzzle. Our plugin-loading code was not using import, but imp.load_module(). The docs for imp.load_module() tell us that repeated calls with the same module reference will act like a reload.
So then I was able to trace the problem to Captain's parsing loading the module multiple times, so I added a sentinal so imp.load_source is only called once and now everything works as expected.
I've added this issue so I have a historical record of what was done.
With a setup like this:
calling on the command line would fail with a TypeError saying
"obj must be an instance or subtype of type"
This was a head scratcher because I couldn't duplicate it just in another script or when I called it from the main method, so this:
worked just fine. I even inspected the argparse code and couldn't see any problems. Turns out:
So then I was able to trace the problem to Captain's parsing loading the module multiple times, so I added a sentinal so
imp.load_source
is only called once and now everything works as expected.I've added this issue so I have a historical record of what was done.