pg.typing.Callable¶
Accessible via pg.typing.Callable.
- class Callable(args=None, kw=None, returns=None, default=MISSING_VALUE, transform=None, callable_type=None, is_noneable=False, frozen=False)[source]¶
Bases:
pg.typing.Generic,ValueSpecBaseValue spec for callable.
Examples:
# A required callable object with any args. pg.typing.Callable() # An optional callable objects with the first argument as int, and the # second argument as float. The field has None as its default value. pg.typing.Callable([pg.typing.Int(), pg.typing.Float()]).noneable() # An callable object that has its first argument as int, and has keyword # arguments 'x' (any type), 'y' (a str) and return value as int. pg.typing.Callable( [pg.typing.Int()], kw=[ ('x', pg.typing.Any()), ('y', pg.typing.Str()) ], returns=pg.typing.Int())
See also:
pg.typing.Functor.Attributes:
Value specs for positional arguments.
Returns forward references used in this spec.
Names and value specs for keyword arguments.
Value spec for return value.
Methods:
format([compact, verbose, root_indent])Format this spec.
is_compatible(other)Returns if current spec can receive all values from the other spec.
to_json(**kwargs)Returns a plain Python value as a representation for this object.
- format(compact=False, verbose=True, root_indent=0, **kwargs)[source]¶
Format this spec.
- Return type:
- property forward_refs: Set[ForwardRef]¶
Returns forward references used in this spec.
- is_compatible(other)[source]¶
Returns if current spec can receive all values from the other spec.
- Return type:
- to_json(**kwargs)[source]¶
Returns a plain Python value as a representation for this object.
A plain Python value are basic python types that can be serialized into JSON, e.g:
bool,int,float,str,dict(with string keys),list,tuplewhere the container types should have plain Python values as their values.