You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fabric.main.is_task_module is currently defined like this:
Determine if the provided value is a task module
#return (type(a) is types.ModuleType and
# any(map(is_task_object, vars(a).values())))
if type(a) is types.ModuleType and a not in _seen:
# Flag module as seen
# Signal that we need to check it out
What's the purpose of type(a) is types.ModuleType? It would be great if isinstance(a, types.ModuleType) is sufficient.
I was trying to use types.ModuleType subclass and fabric fails to discover tasks in this case.
The text was updated successfully, but these errors were encountered:
I don't know offhand why it's done this way. If you want to check the git blame history and see if there was a specific reason, that'd be great. Assuming it's not done on purpose, I'd be fine changing to isinstance.
Yea, that just looks like @goosemo either forgot isinstance is almost always better than type, or figured subclassing from ModuleType was really unlikely. (I admit I was surprised when I heard you were doing so, but there's no reason to actually forbid it :))
If you submit a pull request (don't forget to use hub pull-request to attach it to this issue!) with the change + a changelog entry crediting yourself, I'll merge it. Thanks! You should probably base your PR off the 1.4 branch and not master, by the way, then it can go out in the next 1.4 bugfix release.
By the way, support for ModuleType subclasses is a real problem for me :) We are developing a framework for Fabric and in order to solve #573 without waiting for Fabric 2.0 we're using https://github.com/kmike/fabric-taskset package. The idea is to just create module objects and put them as variables to fabfile (without adding to sys.modules, etc); fabric loads tasks fine from such objects. Creating objects of ModuleType class works fine but sometimes a subclass provides a cleaner solution.