MCPcopy
hub / github.com/google/python-fire / NeedsSeparatingHyphenHyphen

Method NeedsSeparatingHyphenHyphen

fire/trace.py:217–236  ·  view source on GitHub ↗

Returns whether a the trace need '--' before '--help'. '--' is needed when the component takes keyword arguments, when the value of flag matches one of the argument of the component, or the component takes in keyword-only arguments(e.g. argument with default value). Args: fla

(self, flag='help')

Source from the content-addressed store, hash-verified

215 return '\n'.join(lines)
216
217 def NeedsSeparatingHyphenHyphen(self, flag='help'):
218 """Returns whether a the trace need '--' before '--help'.
219
220 '--' is needed when the component takes keyword arguments, when the value of
221 flag matches one of the argument of the component, or the component takes in
222 keyword-only arguments(e.g. argument with default value).
223
224 Args:
225 flag: the flag available for the trace
226
227 Returns:
228 True for needed '--', False otherwise.
229
230 """
231 element = self.GetLastHealthyElement()
232 component = element.component
233 spec = inspectutils.GetFullArgSpec(component)
234 return (spec.varkw is not None
235 or flag in spec.args
236 or flag in spec.kwonlyargs)
237
238
239class FireTraceElement:

Callers 1

UsageTextFunction · 0.80

Calls 1

GetLastHealthyElementMethod · 0.95

Tested by

no test coverage detected