flywheel.fields.types module¶
Field type definitions
-
class
flywheel.fields.types.BinaryType[source]¶ Bases:
flywheel.fields.types.TypeDefinitionBinary strings, stored as a str/bytes
-
coerce(value, force)[source]¶ Check the type of a value and possible convert it
Parameters: - value : object
The value to check
- force : bool
If True, always attempt to convert a bad type to the correct type
Returns: - value : object
A variable of the correct type
Raises: - exc : TypeError or ValueError
If the value is the incorrect type and could not be converted
-
-
class
flywheel.fields.types.BoolType[source]¶ Bases:
flywheel.fields.types.TypeDefinitionBoolean type
-
coerce(value, force)[source]¶ Check the type of a value and possible convert it
Parameters: - value : object
The value to check
- force : bool
If True, always attempt to convert a bad type to the correct type
Returns: - value : object
A variable of the correct type
Raises: - exc : TypeError or ValueError
If the value is the incorrect type and could not be converted
-
-
class
flywheel.fields.types.DateTimeType(naive=False)[source]¶ Bases:
flywheel.fields.types.TypeDefinitionDatetimes, stored as a unix timestamp
Parameters: - naive : bool, optional
If True, will load values from Dynamo with no timezone. If False, will add a UTC timezone. (Default False).
Notes
If you want to use naive datetimes, you will need to reference the type class directly instead of going through an alias. For example:
from flywheel.fields.types import DateTimeType field = Field(data_type=DateTimeType(naive=True))
-
data_type[source]¶ alias of
datetime.datetime
-
class
flywheel.fields.types.DateType[source]¶ Bases:
flywheel.fields.types.TypeDefinitionDates, stored as timestamps
-
data_type[source]¶ alias of
datetime.date
-
-
class
flywheel.fields.types.DecimalType[source]¶ Bases:
flywheel.fields.types.TypeDefinitionNumerical values that use Decimal in the application layer.
This should be used if you want to work with floats but need the additional precision of the Decimal type.
-
coerce(value, force)[source]¶ Check the type of a value and possible convert it
Parameters: - value : object
The value to check
- force : bool
If True, always attempt to convert a bad type to the correct type
Returns: - value : object
A variable of the correct type
Raises: - exc : TypeError or ValueError
If the value is the incorrect type and could not be converted
-
data_type[source]¶ alias of
decimal.Decimal
-
-
class
flywheel.fields.types.DictType[source]¶ Bases:
flywheel.fields.types.TypeDefinitionDict type, stored as a map
-
coerce(value, force)[source]¶ Check the type of a value and possible convert it
Parameters: - value : object
The value to check
- force : bool
If True, always attempt to convert a bad type to the correct type
Returns: - value : object
A variable of the correct type
Raises: - exc : TypeError or ValueError
If the value is the incorrect type and could not be converted
-
-
class
flywheel.fields.types.FloatType[source]¶ Bases:
flywheel.fields.types.TypeDefinitionFloat values
-
coerce(value, force)[source]¶ Check the type of a value and possible convert it
Parameters: - value : object
The value to check
- force : bool
If True, always attempt to convert a bad type to the correct type
Returns: - value : object
A variable of the correct type
Raises: - exc : TypeError or ValueError
If the value is the incorrect type and could not be converted
-
-
class
flywheel.fields.types.IntType[source]¶ Bases:
flywheel.fields.types.TypeDefinitionInteger values (includes longs)
-
coerce(value, force)[source]¶ Check the type of a value and possible convert it
Parameters: - value : object
The value to check
- force : bool
If True, always attempt to convert a bad type to the correct type
Returns: - value : object
A variable of the correct type
Raises: - exc : TypeError or ValueError
If the value is the incorrect type and could not be converted
-
-
class
flywheel.fields.types.ListType[source]¶ Bases:
flywheel.fields.types.TypeDefinitionList type
-
coerce(value, force)[source]¶ Check the type of a value and possible convert it
Parameters: - value : object
The value to check
- force : bool
If True, always attempt to convert a bad type to the correct type
Returns: - value : object
A variable of the correct type
Raises: - exc : TypeError or ValueError
If the value is the incorrect type and could not be converted
-
-
class
flywheel.fields.types.NumberType[source]¶ Bases:
flywheel.fields.types.TypeDefinitionAny kind of numerical value
-
coerce(value, force)[source]¶ Check the type of a value and possible convert it
Parameters: - value : object
The value to check
- force : bool
If True, always attempt to convert a bad type to the correct type
Returns: - value : object
A variable of the correct type
Raises: - exc : TypeError or ValueError
If the value is the incorrect type and could not be converted
-
-
class
flywheel.fields.types.SetType(item_type=None, type_class=None)[source]¶ Bases:
flywheel.fields.types.TypeDefinitionSet types
-
coerce(value, force)[source]¶ Check the type of a value and possible convert it
Parameters: - value : object
The value to check
- force : bool
If True, always attempt to convert a bad type to the correct type
Returns: - value : object
A variable of the correct type
Raises: - exc : TypeError or ValueError
If the value is the incorrect type and could not be converted
-
-
class
flywheel.fields.types.StringType[source]¶ Bases:
flywheel.fields.types.TypeDefinitionString values, stored as unicode
-
coerce(value, force)[source]¶ Check the type of a value and possible convert it
Parameters: - value : object
The value to check
- force : bool
If True, always attempt to convert a bad type to the correct type
Returns: - value : object
A variable of the correct type
Raises: - exc : TypeError or ValueError
If the value is the incorrect type and could not be converted
-
-
class
flywheel.fields.types.TypeDefinition[source]¶ Bases:
flywheel.compat.UnicodeMixinBase class for all Field types
Attributes: - data_type : object
The value you wish to pass in to Field as the data_type.
- aliases : list
Other values that will reference this type if passed to Field
- ddb_data_type : {STRING, BINARY, NUMBER, STRING_SET, BINARY_SET, NUMBER_SET, BOOL, LIST, MAP}
The DynamoDB data type that backs this type
- mutable : bool
If True, flywheel will track updates to this field automatically when making calls to sync()
- allowed_filters : set
The set of filters that can be used on this field type
-
coerce(value, force)[source]¶ Check the type of a value and possible convert it
Parameters: - value : object
The value to check
- force : bool
If True, always attempt to convert a bad type to the correct type
Returns: - value : object
A variable of the correct type
Raises: - exc : TypeError or ValueError
If the value is the incorrect type and could not be converted
-
class
flywheel.fields.types.UTCTimezone[source]¶ Bases:
datetime.tzinfoUTC