pg.typing.Functor¶
Accessible via pg.typing.Functor.
- class Functor(args=None, kw=None, returns=None, default=MISSING_VALUE, transform=None, is_noneable=False, frozen=False)[source]¶
Bases:
pg.typing.CallableValue spec for Functor.
Examples:
# A required PyGlove functor with any args. pg.typing.Functor() # An optional functor with the first argument as int, and the second # argument as float. The field has None as its default value. pg.typing.Functor([pg.typing.Int(), pg.typing.Float()]).noneable() # A functor that has its first argument as int, and has keyword # arguments 'x' (any type), 'y' (a str) and return value as int. pg.typing.Functor( [pg.typing.Int()], kw=[ ('x', pg.typing.Any()), ('y', pg.typing.Str()) ], returns=pg.typing.Int())
See also:
pg.typing.Callable.Methods:
to_json(**kwargs)Returns a plain Python value as a representation for this object.
- 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.