Instagram / Instagram/LibCST

Assigned visit_* methods not being called in BatchableMetadataProvider

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

Description

I am building a metadata provider and running into a pretty strange bug.

If I declare my provider:
```Python
class Provider(cst.BatchableMetadataProvider[bool]):
def _visit_simple_block(self,
node: Union[cst.SimpleStatementLine, cst.SimpleStatementSuite]
) -> Optional[bool]:
... # Operate on node.body

visit_SimpleStatementLine = _visit_simple_block
visit_SimpleStatementSuite = _visit_simple_block
```
`_visit_simple_block` is never called when resolving `Provider`

However if I instead declare it like:
```Python
class Provider(cst.BatchableMetadataProvider[bool]):
...
def visit_SimpleStatementLine(self, node: cst.SimpleStatementLine) -> Optional[bool]:
return self._visit_simple_block(node)

... # similar for visit_SimpleStatementSuite
```
Everything works fine

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.