File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change 20
20
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
# THE SOFTWARE.
22
22
23
+ # mypy: disallow_untyped_defs=True
24
+ # mypy: disallow_untyped_calls=True
23
25
24
26
import curses
25
27
import errno
30
32
import shlex
31
33
32
34
33
- def get_pager_command (default = "less -rf" ):
35
+ def get_pager_command (default : str = "less -rf" ) -> list [ str ] :
34
36
command = shlex .split (os .environ .get ("PAGER" , default ))
35
37
return command
36
38
37
39
38
- def page_internal (data ) :
40
+ def page_internal (data : str ) -> None :
39
41
"""A more than dumb pager function."""
40
42
if hasattr (pydoc , "ttypager" ):
41
43
pydoc .ttypager (data )
42
44
else :
43
45
sys .stdout .write (data )
44
46
45
47
46
- def page (data , use_internal = False ):
48
+ def page (data : str , use_internal : bool = False ) -> None :
47
49
command = get_pager_command ()
48
50
if not command or use_internal :
49
51
page_internal (data )
50
52
else :
51
53
curses .endwin ()
52
54
try :
53
55
popen = subprocess .Popen (command , stdin = subprocess .PIPE )
54
- data = data .encode (sys .__stdout__ .encoding , "replace" )
55
- popen .stdin .write (data )
56
+ data_bytes = data .encode (sys .__stdout__ .encoding , "replace" )
57
+ popen .stdin .write (data_bytes )
56
58
popen .stdin .close ()
57
59
except OSError as e :
58
60
if e .errno == errno .ENOENT :
You can’t perform that action at this time.
0 commit comments