From: John Mulligan Date: Fri, 3 Apr 2026 15:37:30 +0000 (-0400) Subject: python-common: work around some wonky grpc type checking behavior X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=41ce70b96ad7225eee2dc9c175be98ea63f0acfd;p=ceph.git python-common: work around some wonky grpc type checking behavior Enable mypy type checking for gprc related packages that will be consumed within the ceph.smb.ctl package. The google[.protobuf] package causes problems and gets an exception instead of a working stubs dependency - see the extensive comment in the file for more details. Signed-off-by: John Mulligan --- diff --git a/src/mypy.ini b/src/mypy.ini index ccc77021f89..9fe2f82a535 100755 --- a/src/mypy.ini +++ b/src/mypy.ini @@ -77,6 +77,18 @@ ignore_missing_imports = True [mypy-scipy.*] ignore_missing_imports = True +# Ignore errors from inability to import typing stubs for google.protobuf +# package. The stubs exist but mypy gets awfully confused and insists it still +# can't import it. After hours of debugging, I'm not 100% sure, but I think +# this is because ceph (in this config file) disables namespace packages. +# +# If we ever really wanted to properly type-check with this module, a future +# version of ceph could choose to enable namespace packages and fix the +# bindings packages another way or we could split the mypy config between the +# special ceph stuff and the more typical python stuff. +[mypy-google.*] +ignore_missing_imports = True + # Make volumes happy: [mypy-StringIO] ignore_missing_imports = True diff --git a/src/python-common/tox.ini b/src/python-common/tox.ini index 930d818c560..9976a85c6c4 100644 --- a/src/python-common/tox.ini +++ b/src/python-common/tox.ini @@ -14,6 +14,8 @@ commands= deps= -rrequirements.txt -c{toxinidir}/../mypy-constrains.txt + types-grpcio + types-grpcio-reflection commands= mypy --config-file=../mypy.ini -p ceph