-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
We're using mypy with Bazel, which installs dependencies into separate directories and manually places the directories on PYTHONPATH. But it seems like this doesn't play well with protobuf
, probably because of the initial google/
directory. This only seems to happen with protobuf
, can't reproduce with other libraries.
To Reproduce
class FooProto(google.protobuf.message.Message):
x: str
@dataclasses.dataclass
class Foo:
x: str = ""
google.protobuf.message.non_existent()
proto_to_dataclass: Foo = FooProto()
dataclass_to_proto: FooProto = Foo()
See README in https://github.com/brandonchinn178/mypy-repro-protobuf for more details
Expected Behavior
Module has no attribute "non_existent"
Incompatible types in assignment
onproto_to_dataclass
Incompatible types in assignment
ondataclass_to_proto
Actual Behavior
When types-protobuf
and protobuf
are installed in the same venv, this works (whether mypy
is in that environment or a different one). When they're in different venvs, this does not.
Your Environment
- Mypy version used: 1.18.1
- Mypy command-line flags:
- Mypy configuration options from
mypy.ini
(and other config files): - Python version used:
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong