You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
It turns out that part of the issue is that the internal tool we use to wrap buf and protoc does not add any __init__.py files, which makes these folders namespaced packages. Adding the files and then adding the parent folder to mypy.ini seems to have addressed the issue.
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:
It usually works, but once in a while we get:
Regenerating the *_pb2.py and *_pb2.pyi files from scratch does not seem to help, but this seems to work:
or
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 toAny
.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.
The text was updated successfully, but these errors were encountered: