pg.typing.Signature

Accessible via pg.typing.Signature.

class Signature(callable_type, name, module_name, args=None, kwonlyargs=None, varargs=None, varkw=None, return_value=None, qualname=None)[source]

Bases: pg.Formattable

PY3 function signature.

Attributes:

arg_names

Returns names of all arguments according to their declaration order.

has_varargs

Returns whether wildcard positional argument is present.

has_varkw

Returns whether wildcard keyword argument is present.

has_wildcard_args

Returns whether any wildcard arguments are present.

id

Returns ID of the function.

named_args

Returns all named arguments according to their declaration order.

Methods:

format(*args[, markdown])

Format current object.

from_callable(callable_object[, auto_typing])

Creates Signature from a callable object.

from_schema(schema, module_name, name[, ...])

Creates a signature from a schema object.

get_value_spec(name)

Returns Value spec for an argument name.

make_function(body[, exec_globals, exec_locals])

Makes a function with current signature.

property arg_names[source]

Returns names of all arguments according to their declaration order.

format(*args, markdown=False, **kwargs)[source]

Format current object.

Return type:

str

classmethod from_callable(callable_object, auto_typing=False)[source]

Creates Signature from a callable object.

Return type:

pg.typing.Signature

classmethod from_schema(schema, module_name, name, qualname=None, is_method=True)[source]

Creates a signature from a schema object.

Return type:

pg.typing.Signature

Parameters:
  • schema – A pg.typing.Schema object associated with a pg.Object.

  • module_name – Module name for the signature.

  • name – Function or method name of the signature.

  • qualname – Qualname of the signature.

  • is_method – If True, self will be added in the signature as the first argument.

Returns:

A signature object from the schema.

get_value_spec(name)[source]

Returns Value spec for an argument name.

Return type:

Optional[pg.ValueSpec]

Parameters:

name – Argument name.

Returns:

ValueSpec for the requested argument. If name is not found, value spec of wildcard keyword argument will be used. None will be returned if name does not exist in signature and wildcard keyword is not accepted.

property has_varargs: bool[source]

Returns whether wildcard positional argument is present.

property has_varkw: bool[source]

Returns whether wildcard keyword argument is present.

property has_wildcard_args: bool[source]

Returns whether any wildcard arguments are present.

property id: str[source]

Returns ID of the function.

make_function(body, exec_globals=None, exec_locals=None)[source]

Makes a function with current signature.

property named_args[source]

Returns all named arguments according to their declaration order.