mypy fails to identify stubs when defined in custom requirements file #19574
Unanswered
Adityav2410
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a separete resolve for
mypy
and its equivalentmypy-requiremnts.txt
. originally saw this problem when running with protobufs. So my code uses a number of third party libraries,redis
,requests
andprotobuf
. I see 2 issues as described below:types-requests
,types-redis
are defined inpython-default
resolved (requirements.txt), everything passes when i runpants check ::
, but when i move these requiements from defaultrequirements.txt
tomypy-requirements.txt
(and regenerate lockfiles), mypy fails complaining that it cannot find stubs for these libraries.types-protobuf
. So my code also uses protobuf and i am usingmypy_plugin=true
inpants.toml
. If i puttypes-protobuf
as dependency in any requirements file(default requirements.txt ormypy-requirements.txt
), mypy fails to detect stubs, complainingLibrary stubs not installed for "google.protobuf.message"
. But if i add this extra stub inmypy
section ofpants.toml
likeextra_type_stubs = ["types-protobuf"]
, mypants check ::
passes.So overall it seems like,
mypy
doesn't evaluate the dependencies defined inmypy-requirements.txt
when using an explicit resolve formypy
. Also in particular forprotobuf
, it fails to detecttypes-protobuf
unless i pass it explicitly in[mypy]
section of pants.toml.Can someone help me identify what i could be doing wrong? I am on mac m1.
Beta Was this translation helpful? Give feedback.
All reactions