Versioned
has_version = is_versioned
module-attribute
An alias of is_versioned.
Versioned
Bases: Protocol
Represents versioned objects, that is, objects that have the __version__
attribute of type str.
Source code in versions/versioned.py
20 21 22 23 24 25 26 | |
is_versioned(item: Any) -> TypeGuard[Versioned]
Checks if the item implements the Versioned protocol.
That is, whether the item has the __version__ attribute of type str.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item |
Any
|
The item to check. |
required |
Returns:
| Type | Description |
|---|---|
TypeGuard[Versioned]
|
Whether the |
Source code in versions/versioned.py
29 30 31 32 33 34 35 36 37 38 39 40 | |
get_version(item: Versioned, version_type: Type[Version] = Version) -> Version
Fetches the __version__ attribute of the item,
parsing it into the version of version_type, without checking whether the attribute exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
item |
Versioned
|
The item to fetch the version from. |
required |
version_type |
Type[Version]
|
The type of the version to parse. |
Version
|
Returns:
| Type | Description |
|---|---|
Version
|
The version of |
Source code in versions/versioned.py
60 61 62 63 64 65 66 67 68 69 70 71 | |