6868 Tuple ,
6969 Collection ,
7070 Dict ,
71+ TYPE_CHECKING ,
7172)
73+
74+ if TYPE_CHECKING :
75+ from _curses import _CursesWindow
76+
7277from ._typing_compat import Literal
7378import unicodedata
7479from dataclasses import dataclass
@@ -361,7 +366,7 @@ def file_prompt(self, s: str) -> Optional[str]:
361366class CLIRepl (repl .Repl ):
362367 def __init__ (
363368 self ,
364- scr : curses . window ,
369+ scr : "_CursesWindow" ,
365370 interp : repl .Interpreter ,
366371 statusbar : "Statusbar" ,
367372 config : Config ,
@@ -371,7 +376,7 @@ def __init__(
371376 # mypy doesn't quite understand the difference between a class variable with a callable type and a method.
372377 # https://github.com/python/mypy/issues/2427
373378 self .interp .writetb = self .writetb # type:ignore[assignment]
374- self .scr : curses . window = scr
379+ self .scr : "_CursesWindow" = scr
375380 self .stdout_hist = "" # native str (bytes in Py2, unicode in Py3)
376381 self .list_win = newwin (get_colpair (config , "background" ), 1 , 1 , 1 , 1 )
377382 self .cpos = 0
@@ -1631,16 +1636,16 @@ class Statusbar:
16311636
16321637 def __init__ (
16331638 self ,
1634- scr : curses . window ,
1635- pwin : curses . window ,
1639+ scr : "_CursesWindow" ,
1640+ pwin : "_CursesWindow" ,
16361641 background : int ,
16371642 config : Config ,
16381643 s : Optional [str ] = None ,
16391644 c : Optional [int ] = None ,
16401645 ):
16411646 """Initialise the statusbar and display the initial text (if any)"""
16421647 self .size ()
1643- self .win : curses . window = newwin (
1648+ self .win : "_CursesWindow" = newwin (
16441649 background , self .h , self .w , self .y , self .x
16451650 )
16461651
@@ -1767,8 +1772,8 @@ def clear(self) -> None:
17671772
17681773
17691774def init_wins (
1770- scr : curses . window , config : Config
1771- ) -> Tuple [curses . window , Statusbar ]:
1775+ scr : "_CursesWindow" , config : Config
1776+ ) -> Tuple ["_CursesWindow" , Statusbar ]:
17721777 """Initialise the two windows (the main repl interface and the little
17731778 status bar at the bottom with some stuff in it)"""
17741779 # TODO: Document better what stuff is on the status bar.
@@ -1803,12 +1808,12 @@ def init_wins(
18031808 return main_win , statusbar
18041809
18051810
1806- def sigwinch (unused_scr : curses . window ) -> None :
1811+ def sigwinch (unused_scr : "_CursesWindow" ) -> None :
18071812 global DO_RESIZE
18081813 DO_RESIZE = True
18091814
18101815
1811- def sigcont (unused_scr : curses . window ) -> None :
1816+ def sigcont (unused_scr : "_CursesWindow" ) -> None :
18121817 sigwinch (unused_scr )
18131818 # Forces the redraw
18141819 curses .ungetch ("\x00 " )
@@ -1933,7 +1938,7 @@ def __getitem__(self, k: Any) -> int:
19331938 return self ._val
19341939
19351940
1936- def newwin (background : int , * args : int ) -> curses . window :
1941+ def newwin (background : int , * args : int ) -> "_CursesWindow" :
19371942 """Wrapper for curses.newwin to automatically set background colour on any
19381943 newly created window."""
19391944 win = curses .newwin (* args )
@@ -1967,7 +1972,7 @@ def curses_wrapper(func: Callable, *args: Any, **kwargs: Any) -> Any:
19671972
19681973
19691974def main_curses (
1970- scr : curses . window ,
1975+ scr : "_CursesWindow" ,
19711976 args : List [str ],
19721977 config : Config ,
19731978 interactive : bool = True ,
0 commit comments