betty.project.factory - Betty 0.4.0a4 documentation

Hide navigation sidebar
Hide table of contents sidebar
Skip to content
Back to top
Toggle table of contents sidebar

# Source code for betty.project.factory

    """
    Functionality for creating new instances of types that depend on :py:class:`betty.project.Project`.
    """

    from __future__ import annotations

    from abc import ABC, abstractmethod
    from typing import Self, TYPE_CHECKING

    if TYPE_CHECKING:
        from betty.project import Project

    class ProjectDependentFactory(ABC):
        """
        Allow this type to be instantiated using a :py:class:`betty.project.Project`.
        """

        @classmethod
        @abstractmethod
        def new_for_project(cls, project: Project) -> Self:
            """
            Create a new instance.
            """
            pass