pg.typing.Annotated

Accessible via pg.typing.Annotated.

class Annotated(t, docstring=None, metadata=None)[source]

Bases: pg.typing.Generic

The PyGlove enhanced typing.Annotated for defining a class field.

Example:

class A(pg.Object):
  x = pg.typing.Annotated[
      int,                                # Field type or value spec.
      'Docstring for field `x`.',         # Field docstring.
      dict(foo=1, bar=2)                  # Field metadata
  ]
]

Attributes:

docstring

Returns the docstring for the field.

metadata

Returns the metadata for the field.

value_spec

Returns the value spec for the field.

property docstring: str | None[source]

Returns the docstring for the field.

property metadata: Dict[str, Any][source]

Returns the metadata for the field.

property value_spec: ValueSpec[source]

Returns the value spec for the field.