From 62f14597e4cf97524dcc2188add15318aa79da75 Mon Sep 17 00:00:00 2001 From: Adam King Date: Tue, 30 Apr 2024 14:17:58 -0400 Subject: [PATCH] python-common/service_spec: fix some mypy complaints The python/mypy combination on the jenkins nodes the CI is running on don't seem to care, but locally I get mypy: commands[0]> mypy --config-file=../mypy.ini -p ceph 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]" ceph/deployment/service_spec.py:1503: error: Unsupported operand types for > ("int" and "None") [operator] ceph/deployment/service_spec.py:1503: note: Left operand is of type "Optional[int]" ceph/deployment/service_spec.py:1506: error: Unsupported operand types for > ("int" and "None") [operator] ceph/deployment/service_spec.py:1506: note: Left operand is of type "Optional[int]" ceph/deployment/service_spec.py:1509: error: Unsupported operand types for > ("int" and "None") [operator] ceph/deployment/service_spec.py:1509: note: Left operand is of type "Optional[int]" ceph/deployment/service_spec.py:1512: error: Unsupported operand types for > ("int" and "None") [operator] ceph/deployment/service_spec.py:1512: note: Left operand is of type "Optional[int]" ceph/deployment/service_spec.py:1515: error: Unsupported operand types for > ("float" and "None") [operator] ceph/deployment/service_spec.py:1515: note: Left operand is of type "Optional[float]" ceph/deployment/service_spec.py:1518: error: Unsupported operand types for > ("int" and "None") [operator] ceph/deployment/service_spec.py:1518: note: Left operand is of type "Optional[int]" ceph/deployment/service_spec.py:1521: error: Unsupported operand types for > ("int" and "None") [operator] ceph/deployment/service_spec.py:1521: note: Left operand is of type "Optional[int]" ceph/deployment/service_spec.py:1524: error: Unsupported operand types for > ("int" and "None") [operator] ceph/deployment/service_spec.py:1524: note: Left operand is of type "Optional[int]" ceph/deployment/service_spec.py:1527: error: Unsupported operand types for > ("int" and "None") [operator] ceph/deployment/service_spec.py:1527: note: Left operand is of type "Optional[int]" ceph/deployment/service_spec.py:1530: error: Unsupported operand types for > ("float" and "None") [operator] ceph/deployment/service_spec.py:1530: note: Left operand is of type "Optional[float]" Found 12 errors in 1 file (checked 27 source files) The errors make sense to me, so I think we should fix them Signed-off-by: Adam King (cherry picked from commit 7520f65f261c61d01dd75b9722c84147229d9e87) --- .../ceph/deployment/service_spec.py | 60 +++++++++++++++---- 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index cea5ae4e2c49f..912cfee64b7b1 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -1494,40 +1494,76 @@ 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: + if ( + self.state_update_interval_sec + and self.state_update_interval_sec < 0 + ): raise SpecValidationError("State update interval can't be negative") - if self.omap_file_lock_duration < 0: + if ( + self.omap_file_lock_duration + and self.omap_file_lock_duration < 0 + ): raise SpecValidationError("OMAP file lock duration can't be negative") - if self.omap_file_lock_retries < 0: + if ( + self.omap_file_lock_retries + and self.omap_file_lock_retries < 0 + ): raise SpecValidationError("OMAP file lock retries can't be negative") - if self.omap_file_update_reloads < 0: + if ( + self.omap_file_update_reloads + and self.omap_file_update_reloads < 0 + ): raise SpecValidationError("OMAP file reloads can't be negative") - if self.spdk_timeout < 0.0: + if ( + self.spdk_timeout + and self.spdk_timeout < 0.0 + ): raise SpecValidationError("SPDK timeout can't be negative") - if self.conn_retries < 0: + if ( + self.conn_retries + and self.conn_retries < 0 + ): raise SpecValidationError("Connection retries can't be negative") - if self.max_log_file_size_in_mb < 0: + if ( + self.max_log_file_size_in_mb + and self.max_log_file_size_in_mb < 0 + ): raise SpecValidationError("Log file size can't be negative") - if self.max_log_files_count < 0: + if ( + self.max_log_files_count + and self.max_log_files_count < 0 + ): raise SpecValidationError("Log files count can't be negative") - if self.max_log_directory_backups < 0: + if ( + self.max_log_directory_backups + and self.max_log_directory_backups < 0 + ): raise SpecValidationError("Log file directory backups can't be negative") - if self.monitor_timeout < 0.0: + if ( + self.monitor_timeout + and self.monitor_timeout < 0.0 + ): raise SpecValidationError("Monitor timeout can't be negative") if self.port and self.port < 0: -- 2.39.5