Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
tkmeyer opened this issue Jan 21, 2025 · 0 comments

Comments

@tkmeyer
Copy link

tkmeyer commented Jan 21, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant