]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
python-common: fix mypy failure in NVMEoF service spec 57769/head
authorAdam King <adking@redhat.com>
Tue, 16 Apr 2024 16:30:58 +0000 (12:30 -0400)
committerAdam King <adking@redhat.com>
Wed, 29 May 2024 12:45:15 +0000 (08:45 -0400)
Locally, mypy was complaining

```
ceph/deployment/service_spec.py: note: In member "validate" of class "NvmeofServiceSpec":
ceph/deployment/service_spec.py:1497: error: Unsupported operand types for > ("float" and "None")  [operator]
ceph/deployment/service_spec.py:1497: note: Left operand is of type "Optional[float]"
ceph/deployment/service_spec.py:1500: error: Unsupported operand types for > ("int" and "None")  [operator]
ceph/deployment/service_spec.py:1500: note: Left operand is of type "Optional[int]"
```

I'm unsure why those errors didn't show up in the CI,
but they make sense to me, so why not fix them.

Signed-off-by: Adam King <adking@redhat.com>
(cherry picked from commit 1841c4117829f91ec17034acb47494e17085171c)

src/python-common/ceph/deployment/service_spec.py

index 71a332f96f082bd6fc6c7e5f199ea3d1ce7f772d..0f7f0b4900f68e2db02aac773ab300c99922f9b1 100644 (file)
@@ -1494,10 +1494,16 @@ class NvmeofServiceSpec(ServiceSpec):
                 raise SpecValidationError(
                     'Invalid SPDK log level. Valid values are: DEBUG, INFO, WARNING, ERROR, NOTICE')
 
-        if self.spdk_ping_interval_in_seconds < 1.0:
+        if (
+            self.spdk_ping_interval_in_seconds
+            and self.spdk_ping_interval_in_seconds < 1.0
+        ):
             raise SpecValidationError("SPDK ping interval should be at least 1 second")
 
-        if self.allowed_consecutive_spdk_ping_failures < 1:
+        if (
+            self.allowed_consecutive_spdk_ping_failures
+            and self.allowed_consecutive_spdk_ping_failures < 1
+        ):
             raise SpecValidationError("Allowed consecutive SPDK ping failures should be at least 1")
 
         if self.state_update_interval_sec < 0: