]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/cephadm: init attrs created by settattr()
authorKefu Chai <kchai@redhat.com>
Wed, 29 Jan 2020 12:46:45 +0000 (20:46 +0800)
committerKefu Chai <kchai@redhat.com>
Wed, 29 Jan 2020 13:40:49 +0000 (21:40 +0800)
to address the test falure caused by mypy:
```
mypy run-test: commands[0] | mypy --config-file=../../mypy.ini ansible/module.py cephadm/module.py mgr_module.py mgr_util.py orchestrator.py orchestrator_cli/module.py rook/module.py
test_orchestrator/module.py
cephadm/module.py: note: In member "_check_for_strays" of class "CephadmOrchestrator":
cephadm/module.py:596: error: "CephadmOrchestrator" has no attribute "warn_on_stray_hosts"
cephadm/module.py:596: error: "CephadmOrchestrator" has no attribute "warn_on_stray_services"
cephadm/module.py:599: error: "CephadmOrchestrator" has no attribute "warn_on_stray_services"
Found 3 errors in 1 file (checked 8 source files)
```
see also https://github.com/python/mypy/issues/5719

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/pybind/mgr/cephadm/module.py

index d5a44a00d4235bd0ba52a8acd898d04619717684..ba1ffca3ab00f969d9dc292cb10a120bdecefcbd 100644 (file)
@@ -8,8 +8,9 @@ from functools import wraps
 import string
 try:
     from typing import List, Dict, Optional, Callable, TypeVar, Type, Any
+    from typing import TYPE_CHECKING
 except ImportError:
-    pass  # just for type checking
+    TYPE_CHECKING = False  # just for type checking
 
 
 import datetime
@@ -331,6 +332,15 @@ class CephadmOrchestrator(MgrModule, orchestrator.OrchestratorClientMixin):
         self.run = True
         self.event = Event()
 
+        # for mypy which does not run the code
+        if TYPE_CHECKING:
+            self.ssh_config_file = None  # type: Optional[str]
+            self.inventory_cache_timeout = 0
+            self.service_cache_timeout = 0
+            self.mode = ''
+            self.container_image_base = ''
+            self.warn_on_stray_hosts = True
+            self.warn_on_stray_services = True
         self.config_notify()
 
         path = self.get_ceph_option('cephadm_path')