]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: disallow_untyped_defs=True 38533/head
authorSebastian Wagner <sebastian.wagner@suse.com>
Thu, 10 Dec 2020 14:53:00 +0000 (15:53 +0100)
committerSebastian Wagner <sebastian.wagner@suse.com>
Thu, 10 Dec 2020 14:53:00 +0000 (15:53 +0100)
simplifies mypy.ini

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
src/mypy.ini
src/pybind/mgr/cephadm/migrations.py
src/pybind/mgr/cephadm/module.py
src/pybind/mgr/cephadm/remotes.py
src/pybind/mgr/cephadm/template.py
src/pybind/mgr/cephadm/utils.py

index cf8a8b5f4e8931a7ede9f711ae49ccbd4e34c4b4..53b2a5cfd94e7579ae518fbc077d129c8e509297 100755 (executable)
@@ -17,24 +17,7 @@ ignore_missing_imports = True
 # This would require a cephfs.pyi file
 ignore_missing_imports = 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
 
 # Make cephadm and rook happy
index 4837cb19aaf1a9b81e1f2649867d31929583fbde..ee16be58836db5402df55a131facbc4e2d1444dc 100644 (file)
@@ -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)
index 223612e542332e6304b40112b3fd15e283c1faa7..db7c83ed2513b9093ac6cf119fa100ec9e96815c 100644 (file)
@@ -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
index d8cda4e9d9c946bec97ed2c527547aeba4a79101..9165a65048cc189f43de9f65686b5b11c08350e1 100644 (file)
@@ -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)
index 778bc26c0e7715399ca2ac6c957912540bddce36..c59df3f9fb3a6f47b33362eec601e53d02285804 100644 (file)
@@ -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.
 
index 03a28fbd9efe38a5326a5202b558522395c67ddb..752031a5037e1622f3380a89df96a0588edcc59f 100644 (file)
@@ -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: