Skip to content

Commit e52cf86

Browse files
committed
added type references to pager.py, mypy produced no
1 parent 194a000 commit e52cf86

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

bpython/pager.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
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

2426
import curses
2527
import errno
@@ -30,29 +32,29 @@
3032
import shlex
3133

3234

33-
def get_pager_command(default="less -rf"):
35+
def get_pager_command(default: str = "less -rf") -> list[str]:
3436
command = shlex.split(os.environ.get("PAGER", default))
3537
return command
3638

3739

38-
def page_internal(data):
40+
def page_internal(data: str) -> None:
3941
"""A more than dumb pager function."""
4042
if hasattr(pydoc, "ttypager"):
4143
pydoc.ttypager(data)
4244
else:
4345
sys.stdout.write(data)
4446

4547

46-
def page(data, use_internal=False):
48+
def page(data: str, use_internal: bool = False) -> None:
4749
command = get_pager_command()
4850
if not command or use_internal:
4951
page_internal(data)
5052
else:
5153
curses.endwin()
5254
try:
5355
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)
5658
popen.stdin.close()
5759
except OSError as e:
5860
if e.errno == errno.ENOENT:

0 commit comments

Comments
 (0)