]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
python-common: work around some wonky grpc type checking behavior
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 3 Apr 2026 15:37:30 +0000 (11:37 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 27 May 2026 18:26:52 +0000 (14:26 -0400)
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 <jmulligan@redhat.com>
src/mypy.ini
src/python-common/tox.ini

index ccc77021f89c5f56309d5a12a75a3511226c887a..9fe2f82a535df84c3c7d5b2d662e47566dacc5fa 100755 (executable)
@@ -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
index 930d818c560fac7347f9f3dedc0c2239aec0a41f..9976a85c6c4f395b9073d6b3204c9a50a6580a64 100644 (file)
@@ -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