[英]Python Fire module not showing COMMANDS in `-h`
I am using the python Fire
module with an abstract parent class and a child class.我正在使用带有抽象父类和子类的 python Fire
模块。 Not all functions are abstract, some functions do not need to be replicated for each child:并非所有功能都是抽象的,有些功能不需要为每个孩子复制:
from abc import ABC, abstractmethod
class Foo(ABC):
@abstractmethod
def __init__(self, val=None):
# some initialisations
@abstractmethod
def fun1(self, file=None):
# Some calls
def fun2(self):
# Non abastract func... Some calls
import fire
from foo import Foo
class Child(Foo)
def __init__(self, val=None):
super().__init__(val)
# some initialisations
def fun1(file='path/to/file')
# do some stuff
if __name__ == '__main__':
fire.Fire(Child)
when I run python CLI with python -m test --help
I do not get any COMMANDS
ie Fire is not recognising any functions to run.当我使用python -m test --help
运行 python CLI 时,我没有得到任何COMMANDS
,即 Fire 无法识别要运行的任何函数。 However it is recognising the parent global variables and init
flags to set so why is this happening?然而,它正在识别要设置的父全局变量和init
标志,那么为什么会这样呢?
try passing it the instantiated object instead like they do here尝试将实例化对象传递给它,而不是像他们在这里做的那样
fire.Fire(Child())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.