bazel-contrib / bazel-mypy-integration

πŸπŸŒΏπŸ’š Integrate MyPy type-checking into your Python Bazel builds
MIT License
118 stars 44 forks source link

Generated Protobuf library code is not compatible with typeshed's protobuf type stubs #21

Open thundergolfer opened 4 years ago

thundergolfer commented 4 years ago

Not too confident this will be easily fixed on the typeshed side -> https://github.com/python/typeshed/issues/2521

thundergolfer commented 4 years ago

✝️ πŸ‘¨πŸΎβ€βš•οΈ

I think I've got a 'bandaid' solution. Add the following to the mypy.ini:

[mypy-google.protobuf.*]
follow_imports_for_stubs = True
follow_imports = skip

making sure that that config is placed above any more general config like what's shown below.

[mypy-google.*]
ignore_missing_imports = True

The effect is that the (incorrect) protobuf typeshed stubs aren't looked at, and thus the errors within don't break our builds. The relevant piece of the MyPy docs are:

Used in conjunction with follow_imports=skip, this can be used to suppress the import of a module from typeshed, replacing it with Any.