Usage#

As a library#

Look up the installed distribution version:

examples/version_lookup.py#
"""Look up the version of the installed distribution."""

from importlib.metadata import version

DISTRIBUTION_NAME = "litestar_events"


def version_lookup() -> str:
    """Return the installed distribution version for this project.

    Returns:
        str: The installed distribution version.
    """
    return version(DISTRIBUTION_NAME)

For short interactive snippets embedded in prose, the docs-doctest task executes >>> blocks too:

>>> from importlib.metadata import version
>>> isinstance(version("litestar_events"), str)
True