class Signature: (source)
Representation of a Python function signature. Attributes: name: Name of the function. param_names: A tuple of positional parameter names. This DOES include positional-only parameters and does NOT include keyword-only parameters. posonly_count: Number of positional-only parameters. (Python 3.8) varargs_name: Name of the varargs parameter. (The "args" in *args) kwonly_params: Tuple of keyword-only parameters. (Python 3) E.g. ("x", "y") for "def f(a, *, x, y=2)". These do NOT appear in param_names. Ordered like in the source file. kwargs_name: Name of the kwargs parameter. (The "kwargs" in **kwargs) defaults: Dictionary, name to value, for all parameters with default values. annotations: A dictionary of type annotations. (string to type) excluded_types: A set of type names that will be ignored when checking the count of type parameters. type_params: The set of type parameter names that appear in annotations. has_return_annotation: Whether the function has a return annotation. has_param_annotations: Whether the function has parameter annotations. posonly_params: Tuple of positional-only parameters (i.e., the first posonly_count names in param_names).
Class Method | from |
Treat `Any` as `f(...) -> Any`. |
Class Method | from |
Undocumented |
Class Method | from |
Construct a minimal signature from a name and a list of param names. |
Class Method | from |
Construct an abstract signature from a pytd signature. |
Method | __init__ |
Undocumented |
Method | __repr__ |
Undocumented |
Method | add |
Add scope for type parameters in annotations. |
Method | check |
Raises an error if a non-default param follows a default. |
Method | check |
Check the count of type parameters in function. |
Method | del |
Undocumented |
Method | drop |
Undocumented |
Method | get |
Returns the first non-self/cls arg, if any. |
Method | get |
Returns the 'self' or 'cls' arg, if any. |
Method | has |
Undocumented |
Method | insert |
Insert varargs and kwargs from args into the signature. |
Method | iter |
Iterates through the given args, attaching names and expected types. |
Method | mandatory |
Undocumented |
Method | maximum |
Undocumented |
Method | populate |
Populate annotation dict with default values. |
Method | set |
Undocumented |
Instance Variable | annotations |
Undocumented |
Instance Variable | defaults |
Undocumented |
Instance Variable | excluded |
Undocumented |
Instance Variable | kwargs |
Undocumented |
Instance Variable | kwonly |
Undocumented |
Instance Variable | name |
Undocumented |
Instance Variable | param |
Undocumented |
Instance Variable | posonly |
Undocumented |
Instance Variable | type |
Undocumented |
Instance Variable | varargs |
Undocumented |
Property | has |
Undocumented |
Property | has |
Undocumented |
Property | posonly |
Undocumented |
Method | _postprocess |
Postprocess the given annotation. |
Method | _print |
Undocumented |
Method | _print |
Undocumented |
Method | _replace |
Returns a copy of the signature with the specified values replaced. |
Method | _yield |
Yield all the function arguments. |
Constant | _ATTRIBUTES |
Undocumented |
def from_param_names(cls, name, param_names, kind=pytd.ParameterKind.REGULAR): (source) ¶
Construct a minimal signature from a name and a list of param names.
Undocumented
Insert varargs and kwargs from args into the signature. Args: args: An iterable of passed arg names. Returns: A copy of this signature with the passed varargs and kwargs inserted.