Wrong type hint for self.stack in class TypingCollector in docs/source/tutorial.ipynb
- 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
Assessment
This issue has not been assessed yet.