pixano.utils.validation
issubclass_strict(obj, cls, strict=False)
Check if the given object is of the given class type or a subclass of the given class type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj
|
type
|
The object to check. |
required |
cls
|
type
|
The class to compare against. |
required |
strict
|
bool
|
If True, the object must be of the given class type. |
False
|
Returns:
Type | Description |
---|---|
bool
|
True if the object is of the given class type or a subclass of the given class type. |
Source code in pixano/utils/validation.py
validate_and_init_create_at_and_update_at(created_at, updated_at)
Validate and initialize created_at and updated_at.
The validation and initialization of created_at and updated_at is done as follows: - If created_at is None, it is set to the current date and time. - If updated_at is None, it is set to created_at. - If updated_at is not None and created_at is None, a ValueError is raised. - If updated_at is not None and created_at is not None, updated_at should be greater than created_at. - If created_at and updated_at are provided as strings, they are converted to datetime objects from ISO format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
created_at
|
datetime | str | None
|
The creation date of the object. |
required |
updated_at
|
datetime | str | None
|
The last modification date of the object. |
required |
Returns:
Type | Description |
---|---|
tuple[datetime, datetime]
|
A tuple containing the created_at and updated_at. |