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
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I have a separete resolve for
mypyand its equivalentmypy-requiremnts.txt. originally saw this problem when running with protobufs. So my code uses a number of third party libraries,redis,requestsandprotobuf. I see 2 issues as described below:types-requests,types-redisare defined inpython-defaultresolved (requirements.txt), everything passes when i runpants check ::, but when i move these requiements from defaultrequirements.txttomypy-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=trueinpants.toml. If i puttypes-protobufas 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 inmypysection ofpants.tomllikeextra_type_stubs = ["types-protobuf"], mypants check ::passes.So overall it seems like,
mypydoesn't evaluate the dependencies defined inmypy-requirements.txtwhen using an explicit resolve formypy. Also in particular forprotobuf, it fails to detecttypes-protobufunless 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.
All reactions