我使用Python3,希望用一个自定义类包装argparse.ArgumentParser
,该类设置
class CustomParser(argparse.ArgumentParser):
def __init__(self, formatter_class=argparse.RawDescriptionHelpFormatter, **kwargs):
# noinspection PyArgumentList
super().__init__(formatter_class=formatter_class, **kwargs) # warning in this line for the last argument if suppression comment above removed
如果使用IntelliJ suppression命令删除注释,kwargs上的警告"应该是一本字典,得到一个dict",但它仍然有效.这是一个假阳性警告,还是在没有警告的情况下可以做得更好?这一警告背后是否有一个真正的问题,它有助于避免?
Side question: Is there a difference in using
formatter_class = kwargs.pop('formatter_class', argparse.RawDescriptionHelpFormatter)
instead of explicitly defining the named parameter in the signature? According to PEP20 more explicit in the signature is better, right?