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 a Context object if the type annotation of that argument is Context:

>>> 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)


__init__(value, meta, obj)[source]