byoc.Context
- class byoc.Context(value, meta, obj)
Bases:
object
Extra information that can be made available to cast functions.
The cast argument to
param
is must be a function that takes one argument and returns one value. Normally, this argument is simply the value to cast. However, BYOC will instead provide aContext
object if the type annotation of that argument isContext
:>>> import byoc >>> def f(context: byoc.Context): ... return context.value
Context objects have the following attributes:
value
: The value to convert. This is the same value that would normally be passed directly to the cast function.meta
: The metadata object associated with the parameter.obj
: The object that owns the parameter, i.e. self.
Public Methods:
__init__
(value, meta, obj)