MCPcopy Create free account
hub / github.com/python/mypy / formal_arguments

Method formal_arguments

mypy/types.py:1992–2013  ·  view source on GitHub ↗

Yields the formal arguments corresponding to this callable, ignoring *arg and **kwargs. To handle *args and **kwargs, use the 'callable.var_args' and 'callable.kw_args' fields, if they are not None. If you really want to include star args in the yielded output, set the

(self, include_star_args: bool = False)

Source from the content-addressed store, hash-verified

1990 return None
1991
1992 def formal_arguments(self, include_star_args: bool = False) -> list[FormalArgument]:
1993 """Yields the formal arguments corresponding to this callable, ignoring *arg and **kwargs.
1994
1995 To handle *args and **kwargs, use the 'callable.var_args' and 'callable.kw_args' fields,
1996 if they are not None.
1997
1998 If you really want to include star args in the yielded output, set the
1999 'include_star_args' parameter to 'True'."""
2000 args = []
2001 done_with_positional = False
2002 for i in range(len(self.arg_types)):
2003 kind = self.arg_kinds[i]
2004 if kind.is_named() or kind.is_star():
2005 done_with_positional = True
2006 if not include_star_args and kind.is_star():
2007 continue
2008
2009 required = kind.is_required()
2010 pos = None if done_with_positional else i
2011 arg = FormalArgument(self.arg_names[i], pos, self.arg_types[i], required)
2012 args.append(arg)
2013 return args
2014
2015 def argument_by_name(self, name: str | None) -> FormalArgument | None:
2016 if name is None:

Calls 7

rangeClass · 0.85
lenFunction · 0.85
FormalArgumentClass · 0.85
is_namedMethod · 0.80
is_starMethod · 0.80
is_requiredMethod · 0.80
appendMethod · 0.80

Tested by

no test coverage detected