question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid syntax error in generated .pyi file

See original GitHub issue

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?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
nipunn1313commented, Jul 31, 2019

#91 should solve it!

0reactions
nipunn1313commented, Jul 31, 2019

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid syntax error in generated .pyi file · Issue #80 - GitHub
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.
Read more >
Invalid Syntax in Python: Common Reasons for SyntaxError
This means that the Python interpreter got to the end of a line (EOL) before an open string was closed. To fix this,...
Read more >
python - Why do I get the syntax error "SyntaxError: invalid ...
When an error is reported on a line that appears correct, try removing (or commenting out) the line where the error appears to...
Read more >
flake8-pyi - PyPI
flake8-pyi. A plugin for Flake8 that provides specializations for type hinting stub files, especially interesting for linting typeshed.
Read more >
The mypy configuration file - mypy 0.991 documentation
Suppress any error messages generated when your codebase tries importing the module somelibrary . This is useful if somelibrary is some 3rd party...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found