File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change 44from .pager import page
55
66# Ugly monkeypatching
7- pydoc .pager = page
7+ pydoc .pager = page # type: ignore
88
99
1010class _Helper :
Original file line number Diff line number Diff line change 2020# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121# THE SOFTWARE.
2222
23+ # mypy: disallow_untyped_defs=True
24+ # mypy: disallow_untyped_calls=True
2325
2426import curses
2527import errno
2830import subprocess
2931import sys
3032import shlex
33+ from typing import List
3134
3235
33- def get_pager_command (default = "less -rf" ):
36+ def get_pager_command (default : str = "less -rf" ) -> List [ str ] :
3437 command = shlex .split (os .environ .get ("PAGER" , default ))
3538 return command
3639
3740
38- def page_internal (data ) :
41+ def page_internal (data : str ) -> None :
3942 """A more than dumb pager function."""
4043 if hasattr (pydoc , "ttypager" ):
4144 pydoc .ttypager (data )
4245 else :
4346 sys .stdout .write (data )
4447
4548
46- def page (data , use_internal = False ):
49+ def page (data : str , use_internal : bool = False ) -> None :
4750 command = get_pager_command ()
4851 if not command or use_internal :
4952 page_internal (data )
5053 else :
5154 curses .endwin ()
5255 try :
5356 popen = subprocess .Popen (command , stdin = subprocess .PIPE )
54- data = data .encode (sys .__stdout__ .encoding , "replace" )
55- popen .stdin .write (data )
57+ assert popen .stdin is not None
58+ data_bytes = data .encode (sys .__stdout__ .encoding , "replace" )
59+ popen .stdin .write (data_bytes )
5660 popen .stdin .close ()
5761 except OSError as e :
5862 if e .errno == errno .ENOENT :
You can’t perform that action at this time.
0 commit comments