Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitadf19b1

Browse files
authored
added type references to pager.py (#936)
1 parent7702ebd commitadf19b1

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

‎bpython/_internal.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from .pagerimportpage
55

66
# Ugly monkeypatching
7-
pydoc.pager=page
7+
pydoc.pager=page# type: ignore
88

99

1010
class_Helper:

‎bpython/pager.py‎

Lines changed: 9 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
importcurses
2527
importerrno
@@ -28,31 +30,33 @@
2830
importsubprocess
2931
importsys
3032
importshlex
33+
fromtypingimportList
3134

3235

33-
defget_pager_command(default="less -rf"):
36+
defget_pager_command(default:str="less -rf")->List[str]:
3437
command=shlex.split(os.environ.get("PAGER",default))
3538
returncommand
3639

3740

38-
defpage_internal(data):
41+
defpage_internal(data:str)->None:
3942
"""A more than dumb pager function."""
4043
ifhasattr(pydoc,"ttypager"):
4144
pydoc.ttypager(data)
4245
else:
4346
sys.stdout.write(data)
4447

4548

46-
defpage(data,use_internal=False):
49+
defpage(data:str,use_internal:bool=False)->None:
4750
command=get_pager_command()
4851
ifnotcommandoruse_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+
assertpopen.stdinisnotNone
58+
data_bytes=data.encode(sys.__stdout__.encoding,"replace")
59+
popen.stdin.write(data_bytes)
5660
popen.stdin.close()
5761
exceptOSErrorase:
5862
ife.errno==errno.ENOENT:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp