Instagram / Instagram/LibCST

Wrong type hint for self.stack in class TypingCollector in docs/source/tutorial.ipynb

Open
#1,285 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

In `docs/source/tutorial.ipynb`

the type hint for the `self.stack` attribute of `class TypingCollector` is wrong and should read

```python
class TypingCollector(cst.CSTVisitor):
def __init__(self):
# stack for storing the canonical name of the current function
self.stack: List[str] = []
...
```

instead of

```python
class TypingCollector(cst.CSTVisitor):
def __init__(self):
# stack for storing the canonical name of the current function
self.stack: List[Tuple[str, ...]] = [] # wrong type hint
...
```

because the only assignment to `self.stack` in the example is

```python
...
self.stack.append(node.name.value)
...
```

and `node.name.value` is a `str`, not a `Tuple`.
The error will also be flagged by pyright or mypy.

The same applys to `class TypingTransformer` in the same file.

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.