Skip to content

Invalid syntax error in generated .pyi file #80

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

Closed
burk opened this issue Jun 7, 2019 · 5 comments
Closed

Invalid syntax error in generated .pyi file #80

burk opened this issue Jun 7, 2019 · 5 comments

Comments

@burk
Copy link

burk commented Jun 7, 2019

Hey! I've started using your plugin, and it's working to an extent that the type hints are picked up by my IDE, which is helpful.

When trying to run mypy on the command line I get this error however:

com/fish/time/time_range_pb2.pyi:45: error: invalid syntax

The relevant lines:

 42 class TimeRange(google___protobuf___message___Message):
 43 
 44     @property
 45     def from(self) -> google___protobuf___timestamp_pb2___Timestamp: ...
 46 

I'm using this command line to check the types:

mypy --ignore-missing-imports --python-version 3.7 --namespace-packages --check-untyped-defs -p fish

where the com and fish directories reside inside the same directory, and fish is importing protobufs from com.

Before adding the --namespace-packages mypy did finish, but it didn't seem like it took the types of the protobufs into account.

The protobufs are generated by

python3 -m grpc_tools.protoc -I ./proto --python_out=. --mypy_out=. --grpc_python_out=. ./proto/com/fish/*/*.proto

mypy version 0.701, Python 3.7.3

Any ideas?

@nipunn1313
Copy link
Owner

Hi!
Thank you for the report. This was actually only very-recently fixed with #73 - since from is a python literal - we can't actually type messages with a message name from effectively. Look out for a new release of mypy-protobuf shortly

Once it's out, you can do pip install --upgrade mypy-protobuf to pick it up.

@burk
Copy link
Author

burk commented Jun 13, 2019

Ah, I see. Looking forward to the next release!

@burk
Copy link
Author

burk commented Jul 30, 2019

With the new release I'm having the same issue with the class keyword.

@nipunn1313
Copy link
Owner

woops! It appears to be missing from
https://github.com/dropbox/mypy-protobuf/blob/master/python/protoc-gen-mypy#L44

Comparing to https://www.programiz.com/python-programming/keyword-list - it's the only one missing. Going to go ahead and add it and kick a version of mypy-protobuf! Thanks for the catch!

@nipunn1313
Copy link
Owner

#91 should solve it!

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

2 participants