Skip to content

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

@tkmeyer

Description

@tkmeyer

In docs/source/tutorial.ipynb

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

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

instead of

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

...
      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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions