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

Signed-off-by: Sebastian Wagner <sebastian.wagner@suse.com>
(cherry picked from commit a823ee6b1f5a8eb2030c1edf0a7014f86eb719ab)

Conflicts:
src/mypy.ini

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 0c69552c364b16d5a69f8eff8745e6c23c23a5a1..18e54f68c6f4bb3a330bef4ed0cb4aa4a91658cb 100755 (executable)
@@ -5,22 +5,7 @@ ignore_missing_imports = True
 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
 
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 f74cdb85f7a84f024dad1ba997b4449875eecc75..70de61937e9a025e4eea2a84af3cb91041510ee3 100644 (file)
@@ -314,7 +314,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: