diff options
author | Maximilian Hils <git@maximilianhils.com> | 2016-10-16 21:17:39 -0700 |
---|---|---|
committer | Maximilian Hils <git@maximilianhils.com> | 2016-10-16 21:17:39 -0700 |
commit | 9389601025415c47d5efaa6ac371ddca6d543f48 (patch) | |
tree | 7a2fa561d702425ccec7edbc5a35108523e3f33d /mitmproxy/console/grideditor/base.py | |
parent | ae3ff8ee1edc646e7a640219df1a312c27f7c339 (diff) | |
parent | 5a07892bfc58472c1b651f66deaf03176bfe79df (diff) | |
download | mitmproxy-9389601025415c47d5efaa6ac371ddca6d543f48.tar.gz mitmproxy-9389601025415c47d5efaa6ac371ddca6d543f48.tar.bz2 mitmproxy-9389601025415c47d5efaa6ac371ddca6d543f48.zip |
Merge branch 'such-types'
Diffstat (limited to 'mitmproxy/console/grideditor/base.py')
-rw-r--r-- | mitmproxy/console/grideditor/base.py | 56 |
1 files changed, 24 insertions, 32 deletions
diff --git a/mitmproxy/console/grideditor/base.py b/mitmproxy/console/grideditor/base.py index eed70c0b..12c1b3c1 100644 --- a/mitmproxy/console/grideditor/base.py +++ b/mitmproxy/console/grideditor/base.py @@ -1,19 +1,19 @@ from __future__ import absolute_import, print_function, division + import abc import copy +from typing import Any +from typing import Callable +from typing import Container +from typing import Iterable +from typing import Optional +from typing import Sequence +from typing import Tuple import urwid from mitmproxy.console import common from mitmproxy.console import signals -from typing import Any # noqa -from typing import Callable # noqa -from typing import Container # noqa -from typing import Iterable # noqa -from typing import Optional # noqa -from typing import Sequence # noqa -from typing import Tuple # noqa - FOOTER = [ ('heading_key', "enter"), ":edit ", ('heading_key', "q"), ":back ", @@ -30,27 +30,22 @@ class Column(object, metaclass=abc.ABCMeta): self.heading = heading @abc.abstractmethod - def Display(self, data): - # type: () -> Cell + def Display(self, data) -> Cell: pass @abc.abstractmethod - def Edit(self, data): - # type: () -> Cell + def Edit(self, data) -> Cell: pass @abc.abstractmethod - def blank(self): - # type: () -> Any + def blank(self) -> Any: pass - def keypress(self, key, editor): - # type: (str, GridEditor) -> Optional[str] + def keypress(self, key: str, editor: "GridEditor") -> Optional[str]: return key class Cell(urwid.WidgetWrap): - def get_data(self): """ Raises: @@ -65,10 +60,10 @@ class Cell(urwid.WidgetWrap): class GridRow(urwid.WidgetWrap): def __init__( self, - focused, # type: Optional[int] - editing, # type: bool - editor, # type: GridEditor - values # type: Tuple[Iterable[bytes], Container[int] + focused: Optional[int], + editing: bool, + editor: GridEditor, + values: Tuple[Iterable[bytes], Container[int]] ): self.focused = focused self.editor = editor @@ -121,8 +116,8 @@ class GridWalker(urwid.ListWalker): def __init__( self, - lst, # type: Iterable[list] - editor # type: GridEditor + lst: Iterable[list], + editor: GridEditor ): self.lst = [(i, set()) for i in lst] self.editor = editor @@ -263,9 +258,9 @@ class GridEditor(urwid.WidgetWrap): def __init__( self, - master, # type: "mitmproxy.console.master.ConsoleMaster" - value, # type: Any - callback, # type: Callable[..., None] + master: "mitmproxy.console.master.ConsoleMaster", + value: Any, + callback: Callable[..., None], *cb_args, **cb_kwargs ): @@ -368,23 +363,20 @@ class GridEditor(urwid.WidgetWrap): elif column.keypress(key, self) and not self.handle_key(key): return self._w.keypress(size, key) - def data_out(self, data): - # type: (Sequence[list]) -> Any + def data_out(self, data: Sequence[list]) -> Any: """ Called on raw list data, before data is returned through the callback. """ return data - def data_in(self, data): - # type: (Any) -> Iterable[list] + def data_in(self, data: Any) -> Iterable[list]: """ Called to prepare provided data. """ return data - def is_error(self, col, val): - # type: (int, Any) -> Optional[str] + def is_error(self, col: int, val: Any) -> Optional[str]: """ Return None, or a string error message. """ |