Instagram / Instagram/LibCST

metadata providers with matcher decorators

Open
#800 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.9k
Forks
229
PR merge metrics
No merged PRs in 30d

Description

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

It can look so:
```py
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)

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.