linkd.utils

class Marker(name: str)[source]

Simple class intended to be used in place of when you’d use an object as a marker, in order to provide a better repr.

Parameters:

name – The name of the marker.

Example

>>> FOO = object()
>>> FOO
<object object at 0x104cdc5f0>
>>> BAR = Marker("BAR")
>>> BAR
<linkd.Marker: BAR>
get_dependency_id(dependency_type: Any) str[source]

Get the dependency id of the given type. This is used when storing and retrieving dependencies from registries and containers.

Parameters:

dependency_type – The type to get the dependency id for.

Returns:

The dependency id for the given type.

async maybe_await(item: T | Coroutine[Any, Any, T]) T[source]

Await the given item if it is a coroutine, otherwise just return the given item.

Parameters:

item – The item to maybe await.

Returns:

The item, or the return once the item was awaited.

MaybeAwaitable

TypeAlias for an item that might be able to be awaited.

alias of T | Coroutine[Any, Any, T]