Skip to content

Commit

Permalink
mgr/cephadm: init attrs created by settattr()
Browse files Browse the repository at this point in the history
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 python/mypy#5719

Signed-off-by: Kefu Chai <kchai@redhat.com>
  • Loading branch information
tchaikov committed Jan 29, 2020
1 parent ec2e53f commit 7c8e3e8
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/pybind/mgr/cephadm/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
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
Expand Down Expand Up @@ -331,6 +332,15 @@ def __init__(self, *args, **kwargs):
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')
Expand Down

0 comments on commit 7c8e3e8

Please sign in to comment.