For curses programming in Python 3, it is useful to use the curses.wrapper function to encapsulate the curses program, to handle errors and setup.
import curses
def main(stdscr):
# Curses program here
pass
curses.wrapper(main)
But how do you add type hinting to the stdscr object? Adding type hinting would allow IDEs to provide better intellisense to the stdscr object and show available methods and properties. (I'm using Visual Studio Code btw)
The following code:
import curses
def main(stdscr):
s = str(type(stdscr))
stdscr.clear()
stdscr.addstr(0,0,s)
stdscr.refresh()
stdscr.getkey()
curses.wrapper(main)
...shows that type(stdscr) is <class '_curses.window'>
However this does not work:
import curses
import _curses
# This does not work:
def main(stdscr: _curses.window):
# No intellisense provided for stdscr
pass
curses.wrapper(main)
And I'm not exactly sure what else to try.