Skip to content

Imports in generated files aren't findable by mypy #681

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

Open
brandonchinn178 opened this issue Apr 4, 2025 · 0 comments
Open

Imports in generated files aren't findable by mypy #681

brandonchinn178 opened this issue Apr 4, 2025 · 0 comments

Comments

@brandonchinn178
Copy link

brandonchinn178 commented Apr 4, 2025

Maybe I'm not installing the tool right, but I'm getting type errors on the import statements that mypy-protobuf generates.

Repro steps:

  1. python3 -m venv venv
  2. venv/bin/pip install mypy types-protobuf
  3. Download https://github.com/nipunn1313/mypy-protobuf/blob/main/test/generated/mypy_protobuf/extensions_pb2.pyi
  4. venv/bin/mypy extensions_pb2.pyi
extensions_pb2.pyi:7: error: Cannot find implementation or library stub for module named "google"  [import-not-found]
extensions_pb2.pyi:7: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
Found 1 error in 1 file (checked 1 source file)

Related to python/mypy#16149

By itself, this doesn't really matter to us, since we ignore all errors in the generated _pb2.pyi files anyway, but typechecking anything from the generated files with --strict errors because everything is typed as Any, e.g. MyEnum.Value("foo") # Any

@brandonchinn178 brandonchinn178 changed the title Imports in generated files don't work Imports in generated files aren't findable by mypy Apr 4, 2025
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