From c9e219c1405604f2ef81b3e446cc33a0492af42d Mon Sep 17 00:00:00 2001 From: mathieui Date: Thu, 28 May 2020 21:31:18 +0200 Subject: mypy: Reduce errors on muctab.py by a lot --- poezio/core/structs.py | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'poezio/core/structs.py') diff --git a/poezio/core/structs.py b/poezio/core/structs.py index 72c9628a..a75f1e94 100644 --- a/poezio/core/structs.py +++ b/poezio/core/structs.py @@ -1,6 +1,8 @@ """ Module defining structures useful to the core class and related methods """ +from dataclasses import dataclass +from typing import Any, Callable, List, Dict __all__ = [ 'ERROR_AND_STATUS_CODES', 'DEPRECATED_ERRORS', 'POSSIBLE_SHOW', 'Status', @@ -51,23 +53,11 @@ POSSIBLE_SHOW = { } +@dataclass class Status: __slots__ = ('show', 'message') - - def __init__(self, show, message): - self.show = show - self.message = message - - -class Command: - __slots__ = ('func', 'desc', 'comp', 'short_desc', 'usage') - - def __init__(self, func, desc, comp, short_desc, usage): - self.func = func - self.desc = desc - self.comp = comp - self.short_desc = short_desc - self.usage = usage + show: str + message: str class Completion: @@ -75,8 +65,13 @@ class Completion: A completion result essentially currying the input completion call. """ __slots__ = ['func', 'args', 'kwargs', 'comp_list'] - - def __init__(self, func, comp_list, *args, **kwargs): + def __init__( + self, + func: Callable[..., Any], + comp_list: List[str], + *args: Any, + **kwargs: Any + ) -> None: self.func = func self.comp_list = comp_list self.args = args @@ -84,3 +79,12 @@ class Completion: def run(self): return self.func(self.comp_list, *self.args, **self.kwargs) + +@dataclass +class Command: + __slots__ = ('func', 'desc', 'comp', 'short_desc', 'usage') + func: Callable[..., Any] + desc: str + comp: Callable[['windows.Input'], Completion] + short_desc: str + usage: str -- cgit v1.2.3