Types in the module
This section showcases classes and types extracted from the module example.
- class EnumType
Bases:
Enum
- enabled = 'enabled'
Documents the enumeration member enabled.
- disabled = 'disabled'
Documents the enumeration member disabled.
- active = 'active'
- inactive = 'inactive'
- exception MyException
Bases:
Exception
A custom exception type.
- class PlainClass
A plain class.
- Parameters:
timestamp (datetime) – A member variable of type datetime.
- class SampleClass
A data-class with several member variables.
Class doc-strings can include code blocks.
A code block formatted as HTML:
<html> <body> <p>A paragraph.</p> </body> </html>
A code block formatted as Python:
if sys.version_info > (3, 10): SimpleType = bool | int | float | str
- Parameters:
boolean (bool) – A member variable of type bool.
integer (int) – A member variable of type int.
double (float) – A member variable of type float.
string (str) – A member variable of type str.
enumeration (EnumType) – A member variable with an enumeration type.
- __lt__(other: SampleClass) bool
A custom implementation for less than.
- __le__(other: SampleClass) bool
A custom implementation for less than or equal.
- __ge__(other: SampleClass) bool
A custom implementation for greater than or equal.
- __gt__(other: SampleClass) bool
A custom implementation for greater than.
- to_json() json
Serializes the data to JSON.
- Returns:
A JSON object.
- static from_json(obj: json) SampleClass
De-serializes the data from JSON.
- Parameters:
obj (json) – A JSON object.
- Returns:
An instance of this class.
- class DerivedClass
Bases:
SampleClass
This data-class derives from another base class.
- Parameters:
union (bool | int | float | str) – A union of several types.
json (json) – A complex type with type substitution.
schema (Dict[str, None | bool | int | float | str | Dict[str, JsonType] | List[JsonType]]) – A complex type without type substitution.
- class FixedWidthIntegers
Fixed-width integers have a compact representation.
- Parameters:
integer8 (int8) – A signed integer of 8 bits.
integer16 (int16) – A signed integer of 16 bits.
unsigned32 (uint32) – An unsigned integer of 32 bits.
unsigned64 (uint64) – An unsigned integer of 64 bits.
- class LookupTable
This table maps an integer key to a string value.
- Parameters:
id (int) – 🔑 Primary key.
value (str) – Lookup value.
- class EntityTable
This class represents a table in a database or data warehouse.
- Parameters:
primary_key (int) – 🔑 Primary key of the table.
updated_at (datetime) – The time the record was created or last modified.
foreign_key (LookupTable) – A column with a foreign key to another table.
unique_key (str) – ◉ A column with unique values only.
Functions in the module
This section showcases functions extracted from the module example.
- send_message(sender: str, recipient: str, message_body: str, priority: int = 1) int
- Parameters:
sender (str) – The person sending the message.
recipient (str) – The recipient of the message.
message_body (str) – The body of the message.
priority (int) – The priority of the message, can be a number 1-5.
- Returns:
The message identifier.