-
Notifications
You must be signed in to change notification settings - Fork 84
Description
We have a private repository with protobufs used by go and python code.
We use the latest releases of python, mypy, mypy-protobuf, protoc, buf, etc... and in recent weeks we are seeing some odd errors on the imports when mypy is analyzing our python code.
If the import is in this format:
from project.foo.bar import baz_pb2
It usually works, but once in a while we get:
Module "project.foo.bar" has no attribute "baz_pb2" [attr-defined]
Regenerating the *_pb2.py and *_pb2.pyi files from scratch does not seem to help, but this seems to work:
import project.foo.bar.baz_pb2
or
import project.foo.bar.baz_pb2 import baz_pb2
I had this happen for a couple of pb2 imports 2-3 weeks ago, then the problem went away, now it is happening to more _pb2 imports, but not all. The other issues, is that mypy no longer report any typing errors and all the proto objects are pretty much equivalent to Any.
I tried to re-install python from scratch, purge __pycache__ folders, the mypy cache, the pip caches, nothing seems to help besides doing a direct import of the modules.
Fortunately our CI pipelines are not impacted but this makes it very difficult for me to use and trust mypy locally now.