summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr
diff options
context:
space:
mode:
authorSebastian Wagner <sebastian.wagner@suse.com>2020-12-10 15:53:00 +0100
committerSebastian Wagner <sebastian.wagner@suse.com>2020-12-10 15:53:00 +0100
commita823ee6b1f5a8eb2030c1edf0a7014f86eb719ab (patch)
tree165d6c68268c74d5280dadeea99db4fc00ec0a97 /src/pybind/mgr
parentMerge pull request #38524 from tchaikov/wip-crimson-qa-rbd (diff)
downloadceph-a823ee6b1f5a8eb2030c1edf0a7014f86eb719ab.tar.xz
ceph-a823ee6b1f5a8eb2030c1edf0a7014f86eb719ab.zip
mgr/cephadm: disallow_untyped_defs=True
simplifies mypy.ini Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
Diffstat (limited to 'src/pybind/mgr')
-rw-r--r--src/pybind/mgr/cephadm/migrations.py8
-rw-r--r--src/pybind/mgr/cephadm/module.py2
-rw-r--r--src/pybind/mgr/cephadm/remotes.py8
-rw-r--r--src/pybind/mgr/cephadm/template.py6
-rw-r--r--src/pybind/mgr/cephadm/utils.py6
5 files changed, 16 insertions, 14 deletions
diff --git a/src/pybind/mgr/cephadm/migrations.py b/src/pybind/mgr/cephadm/migrations.py
index 4837cb19aaf..ee16be58836 100644
--- a/src/pybind/mgr/cephadm/migrations.py
+++ b/src/pybind/mgr/cephadm/migrations.py
@@ -36,20 +36,20 @@ class Migrations:
# let's try to shortcut things here.
self.migrate()
- def set(self, val):
+ def set(self, val: int) -> None:
self.mgr.set_module_option('migration_current', val)
self.mgr.migration_current = val
- def is_migration_ongoing(self):
+ def is_migration_ongoing(self) -> bool:
return self.mgr.migration_current != LAST_MIGRATION
- def verify_no_migration(self):
+ def verify_no_migration(self) -> None:
if self.is_migration_ongoing():
# this is raised in module.serve()
raise OrchestratorError(
"cephadm migration still ongoing. Please wait, until the migration is complete.")
- def migrate(self):
+ def migrate(self) -> None:
if self.mgr.migration_current == 0:
if self.migrate_0_1():
self.set(1)
diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py
index 223612e5423..db7c83ed251 100644
--- a/src/pybind/mgr/cephadm/module.py
+++ b/src/pybind/mgr/cephadm/module.py
@@ -327,7 +327,7 @@ class CephadmOrchestrator(orchestrator.Orchestrator, MgrModule,
self.allow_ptrace = False
self.container_init = False
self.prometheus_alerts_path = ''
- self.migration_current = None
+ self.migration_current: Optional[int] = None
self.config_dashboard = True
self.manage_etc_ceph_ceph_conf = True
self.registry_url: Optional[str] = None
diff --git a/src/pybind/mgr/cephadm/remotes.py b/src/pybind/mgr/cephadm/remotes.py
index d8cda4e9d9c..9165a65048c 100644
--- a/src/pybind/mgr/cephadm/remotes.py
+++ b/src/pybind/mgr/cephadm/remotes.py
@@ -1,8 +1,9 @@
# ceph-deploy ftw
import os
-import errno
-import tempfile
-import shutil
+try:
+ from typing import Optional
+except ImportError:
+ pass
PYTHONS = ['python3', 'python2', 'python']
PATH = [
@@ -16,6 +17,7 @@ PATH = [
def choose_python():
+ # type: () -> Optional[str]
for e in PYTHONS:
for b in PATH:
p = os.path.join(b, e)
diff --git a/src/pybind/mgr/cephadm/template.py b/src/pybind/mgr/cephadm/template.py
index 778bc26c0e7..c59df3f9fb3 100644
--- a/src/pybind/mgr/cephadm/template.py
+++ b/src/pybind/mgr/cephadm/template.py
@@ -26,7 +26,7 @@ class TemplateEngine:
class Jinja2Engine(TemplateEngine):
- def __init__(self):
+ def __init__(self) -> None:
self.env = Environment(
loader=PackageLoader('cephadm', 'templates'),
autoescape=select_autoescape(['html', 'xml'], default_for_string=False),
@@ -46,7 +46,7 @@ class Jinja2Engine(TemplateEngine):
except j2_exceptions.TemplateNotFound as e:
raise TemplateNotFoundError(e.message)
- def render_plain(self, source, context):
+ def render_plain(self, source: str, context: Optional[dict]) -> str:
try:
template = self.env.from_string(source)
if context is None:
@@ -68,7 +68,7 @@ class TemplateMgr:
def render(self, name: str,
context: Optional[dict] = None,
- managed_context=True,
+ managed_context: bool = True,
host: Optional[str] = None) -> str:
"""Render a string from a template with context.
diff --git a/src/pybind/mgr/cephadm/utils.py b/src/pybind/mgr/cephadm/utils.py
index 03a28fbd9ef..752031a5037 100644
--- a/src/pybind/mgr/cephadm/utils.py
+++ b/src/pybind/mgr/cephadm/utils.py
@@ -4,7 +4,7 @@ import json
import datetime
from enum import Enum
from functools import wraps
-from typing import Optional, Callable, TypeVar, List, NewType, TYPE_CHECKING
+from typing import Optional, Callable, TypeVar, List, NewType, TYPE_CHECKING, Any
from orchestrator import OrchestratorError
if TYPE_CHECKING:
@@ -41,7 +41,7 @@ def name_to_config_section(name: str) -> ConfEntity:
def forall_hosts(f: Callable[..., T]) -> Callable[..., List[T]]:
@wraps(f)
- def forall_hosts_wrapper(*args) -> List[T]:
+ def forall_hosts_wrapper(*args: Any) -> List[T]:
from cephadm.module import CephadmOrchestrator
# Some weired logic to make calling functions with multiple arguments work.
@@ -53,7 +53,7 @@ def forall_hosts(f: Callable[..., T]) -> Callable[..., List[T]]:
else:
assert 'either f([...]) or self.f([...])'
- def do_work(arg):
+ def do_work(arg: Any) -> T:
if not isinstance(arg, tuple):
arg = (arg, )
try: