LibCST icon indicating copy to clipboard operation
LibCST copied to clipboard

metadata providers with matcher decorators

Open gggrafff opened this issue 2 years ago • 0 comments

Matcher decorators are beatyfull, what think you about to support it for metadata providers?

It can look so:

from typing import TypeVar

from libcst import BaseMetadataProvider, matchers as m
from libcst._nodes.module import _ModuleSelfT as _ModuleT


_ProvidedMetadataT = TypeVar("_ProvidedMetadataT", covariant=True)


class MatcherDecoratableMetadataProvider(m.MatcherDecoratableVisitor, BaseMetadataProvider[_ProvidedMetadataT]):
    """
    The low-level base class for all non-batchable visitor-based metadata
    providers. Inherits from :class:`~libcst.matchers.MatcherDecoratableVisitor`.

    This class is generic. A subclass of ``MatcherDecoratableMetadataProvider[T]`` will
    provider metadata of type ``T``.
    """

    def _gen_impl(self, module: "_ModuleT") -> None:
        module.visit(self)

gggrafff avatar Oct 24 '22 11:10 gggrafff