Skip to content

Commit 7f81e52

Browse files
committed
Create a submodule named type to contain local type hinting.
1 parent e35cf0d commit 7f81e52

File tree

6 files changed

+37
-30
lines changed

6 files changed

+37
-30
lines changed

visualdialog/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66

77
from .box import *
88
from .dialog import *
9+
from .type import *
910
from .utils import *

visualdialog/box.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
import curses.textpad
99
from typing import List, Literal, Sequence, Tuple, Union
1010

11-
from .utils import (CursesKey, CursesKeys,
12-
CursesTextAttribute, CursesTextAttributes,
13-
CursesWindow, TextAttr)
11+
from .type import CursesKey, CursesTextAttribute, CursesTextAttributes, CursesWindow
12+
from .utils import TextAttr
1413

1514

1615
class PanicError(Exception):
@@ -210,6 +209,3 @@ def get_input(self, win: CursesWindow):
210209
break
211210
elif key in self.panic_keys:
212211
raise PanicError(key)
213-
else:
214-
# Ignore incorrect keys.
215-
...

visualdialog/choices.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from typing import Any, Mapping, Tuple, Union
66

77
from .dialog import DialogBox
8-
from .utils import CursesTextAttributes, TextAttr, chunked
8+
from .type import *
9+
from .utils import TextAttr, chunked
910

1011

1112
class ChoiceBox(DialogBox):

visualdialog/dialog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
from typing import Any, Callable, List, Mapping, Sequence, Tuple, Union
1010

1111
from .box import BaseTextBox
12-
from .utils import (CursesTextAttribute, CursesTextAttributes,
13-
CursesWindow, TextAttr, chunked)
12+
from .type import CursesTextAttribute, CursesTextAttributes, CursesWindow
13+
from .utils import TextAttr, chunked
1414

1515

1616
class DialogBox(BaseTextBox):

visualdialog/type.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# type.py
2+
# 2020 Timéo Arnouts <[email protected]>
3+
4+
__all__ = [
5+
"CursesWindow",
6+
"CursesTextAttribute",
7+
"CursesTextAttributes",
8+
"CursesKey",
9+
"CursesKeys",
10+
"CursesWindow"
11+
]
12+
13+
from typing import Sequence, Union
14+
15+
import _curses
16+
17+
CursesWindow = _curses.window
18+
19+
#: curses key constants are integers or strings depending on input method used.
20+
#: See https://docs.python.org/3/library/curses.html?#constants
21+
CursesKey = Union[int, str]
22+
CursesKeys = Sequence[CursesKey]
23+
24+
#: curses text attribute constants are integers.
25+
#: See https://docs.python.org/3/library/curses.html?#constants
26+
CursesTextAttribute = int
27+
CursesTextAttributes = Sequence[CursesTextAttribute]

visualdialog/utils.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,12 @@
11
# utils.py
22
# 2020 Timéo Arnouts <[email protected]>
33

4-
__all__ = ["CursesWindow",
5-
"CursesTextAttribute",
6-
"CursesTextAttributes",
7-
"CursesKey",
8-
"CursesKeys",
9-
"CursesWindow",
10-
"TextAttr"]
4+
__all__ = ["TextAttr"]
115

126
from contextlib import ContextDecorator
13-
from typing import Iterable, NoReturn, Sequence, Union
7+
from typing import Iterable, NoReturn, Sequence
148

15-
import _curses
16-
17-
CursesWindow = _curses.window
18-
19-
#: curses key constants are integers or strings depending on input method used..
20-
#: See https://docs.python.org/3/library/curses.html?#constants
21-
CursesKey = Union[int, str]
22-
CursesKeys = Sequence[CursesKey]
23-
24-
#: curses text attribute constants are integers.
25-
#: See https://docs.python.org/3/library/curses.html?#constants
26-
CursesTextAttribute = int
27-
CursesTextAttributes = Sequence[CursesTextAttribute]
9+
from .type import CursesTextAttribute, CursesWindow
2810

2911

3012
def chunked(seq: Sequence,

0 commit comments

Comments
 (0)