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

mypy CSTTypedTransformerFunctions issue #161

Closed
zhammer opened this issue Dec 5, 2019 · 0 comments · Fixed by #162
Closed

mypy CSTTypedTransformerFunctions issue #161

zhammer opened this issue Dec 5, 2019 · 0 comments · Fixed by #162

Comments

@zhammer
Copy link
Contributor

zhammer commented Dec 5, 2019

context

ran into a peculiar bug where the CSTTypedTransformerFunctions types seem to not work with mypy. leave_{Node} calls fail mypy type check with Signature of "leave_{Node}" is incompatible with supertype "CSTTypedTransformerFunctions".

the type definition that mypy says is incompatible doesnt look incompatible to me, though:

@mark_no_op
def leave_Module(self, original_node: "Module", updated_node: "Module") -> "Module":
return updated_node

i'm not sure yet if this is an issue with mypy or libcst, but wanted to share here for replication. (mypy's error messages aren't super descriptive so am still trying to figure out where mypy is getting the incompatible defintion from.)

replicate (using: python 3.7.5)

./requirements.txt

libcst==0.2.4
mypy==0.750

./transformer.py

import libcst

class Transformer(libcst.CSTTransformer):

    def leave_Module(self, original_node: libcst.Module, updated_node: libcst.Module) -> libcst.Module:
        return updated_node

    def leave_Call(self, original_node: libcst.Call, updated_node: libcst.Call) -> libcst.Call:
        return updated_node

mypy errors

$ mypy transformer.py 
transformer.py:5: error: Signature of "leave_Module" incompatible with supertype "CSTTypedTransformerFunctions"
transformer.py:8: error: Signature of "leave_Call" incompatible with supertype "CSTTypedTransformerFunctions"
Found 2 errors in 1 file (checked 1 source 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

Successfully merging a pull request may close this issue.

1 participant