Skip to content

confingy.mypy_plugin#

mypy_plugin #

Mypy plugin for confingy.

This plugin teaches mypy that classes decorated with @track have a .lazy() classmethod that returns Lazy[T] where T is the class type.

To use this plugin, add to your mypy.ini or pyproject.toml:

[mypy]
plugins = confingy.mypy_plugin

Or in pyproject.toml:

[tool.mypy]
plugins = ["confingy.mypy_plugin"]

ConfingyPlugin #

Bases: Plugin

Mypy plugin for confingy.

Source code in src/confingy/mypy_plugin.py
71
72
73
74
75
76
77
78
79
80
class ConfingyPlugin(Plugin):
    """Mypy plugin for confingy."""

    def get_class_decorator_hook(
        self, fullname: str
    ) -> Callable[[ClassDefContext], None] | None:
        """Hook for class decorators."""
        if fullname in ("confingy.track", "confingy.tracking.track"):
            return _track_class_decorator_callback
        return None

get_class_decorator_hook #

get_class_decorator_hook(
    fullname: str,
) -> Callable[[ClassDefContext], None] | None

Hook for class decorators.

Source code in src/confingy/mypy_plugin.py
74
75
76
77
78
79
80
def get_class_decorator_hook(
    self, fullname: str
) -> Callable[[ClassDefContext], None] | None:
    """Hook for class decorators."""
    if fullname in ("confingy.track", "confingy.tracking.track"):
        return _track_class_decorator_callback
    return None

plugin #

plugin(version: str) -> type[Plugin]

Entry point for mypy plugin.

Source code in src/confingy/mypy_plugin.py
83
84
85
def plugin(version: str) -> type[Plugin]:
    """Entry point for mypy plugin."""
    return ConfingyPlugin