fields
Special field types for type-annotating class variables in a JsonObject.
- class CustomField(arg)[source]
Bases:
ABC
Abstract base class for defining custom field types in a JsonObject.
- abstract property as_dtype
How should instances appear in cells of a pandas Series?
- abstract property as_json
How should instances be represented in a JSON-serializable dict?
- class FlexiDate(date)[source]
Bases:
object
Flexible wrapper around python’s own
datetime.date
object.- Parameters:
date – Can be an ISO string of a date or datetime, a
datetime.date
or adatetime.datetime
object, or apandas.Timestamp
.
- property as_datetime
Date as a datetime object.
- property as_dtype
Representation in a pandas DataFrame.
- property as_json
Representation to appear in a JSON.
- class FlexiTime(time)[source]
Bases:
object
Flexible wrapper around python’s own
datetime.datetime
object.- Parameters:
time – Can be an ISO string of a date or datetime, a
datetime.date
or adatetime.datetime
object, or apandas.Timestamp
.
- property as_dtype
Representation in a pandas DataFrame.
- property as_json
Representation to appear in a JSON.
- class Lower(lstrip=None, rstrip=None)[source]
Bases:
ArgRepr
Lowercase strings, optionally stripping characters left and/or right.
- Parameters:
lstrip (str, optional) – Characters to strip from the left of a string. Defaults to
None
, resulting in only whitespaces to be stripped.rstrip (str, optional) – Characters to strip from the right of a string. Defaults to
None
, resulting in only whitespaces to be stripped.
- class Maybe(cast)[source]
Bases:
Generic
Type annotation to allow for
None
values.Initialize this class with a built-in type, class, or other callable that will cast a given value to the desired type if it is not
None
. Then calling the callable instance on that value will return the desired type if the value is notNone
andNone
if it is.- Parameters:
cast (callable) – Casts value to desired type if value is not
None
.
Note
Upon instantiation, the generic class can be type-annotated with the return type of cast.