warn_incomplete_stub = True
check_untyped_defs = True
show_error_context = True
-[mypy-cephadm.services.*]
-disallow_untyped_defs = True
-
-[mypy-cephadm.upgrade.*]
-disallow_untyped_defs = True
-
-[mypy-cephadm.serve.*]
-disallow_untyped_defs = True
-
-[mypy-cephadm.inventory]
-disallow_untyped_defs = True
-
-[mypy-cephadm.schedule]
-disallow_untyped_defs = True
-
-[mypy-cephadm.module]
+[mypy-cephadm.*]
disallow_untyped_defs = True
# 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)
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
# ceph-deploy ftw
import os
-import errno
-import tempfile
-import shutil
+try:
+ from typing import Optional
+except ImportError:
+ pass
PYTHONS = ['python3', 'python2', 'python']
PATH = [
def choose_python():
+ # type: () -> Optional[str]
for e in PYTHONS:
for b in PATH:
p = os.path.join(b, e)
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),
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:
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.
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:
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.
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: