Skip to content

Commit 465fdaa

Browse files
authored
Update pydoc for Python 3.13 (#12305)
1 parent 9f24a1f commit 465fdaa

File tree

2 files changed

+30
-12
lines changed

2 files changed

+30
-12
lines changed

stdlib/@tests/stubtest_allowlists/py313.txt

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,6 @@ os.path.splitroot
106106
# `__replace__` to be special cased in dataclasses
107107
pstats.FunctionProfile.__replace__
108108
pstats.StatsProfile.__replace__
109-
pydoc.pager
110-
pydoc.pipepager
111-
pydoc.plainpager
112-
pydoc.tempfilepager
113-
pydoc.ttypager
114109
site.gethistoryfile
115110
site.register_readline
116111
sre_compile.SRE_FLAG_TEMPLATE

stdlib/pydoc.pyi

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ from builtins import list as _list # "list" conflicts with method name
55
from collections.abc import Callable, Container, Mapping, MutableMapping
66
from reprlib import Repr
77
from types import MethodType, ModuleType, TracebackType
8-
from typing import IO, Any, AnyStr, Final, NoReturn, TypeVar
8+
from typing import IO, Any, AnyStr, Final, NoReturn, Protocol, TypeVar
99
from typing_extensions import TypeGuard
1010

1111
__all__ = ["help"]
@@ -17,6 +17,9 @@ __date__: Final[str]
1717
__version__: Final[str]
1818
__credits__: Final[str]
1919

20+
class _Pager(Protocol):
21+
def __call__(self, text: str, title: str = "") -> None: ...
22+
2023
def pathdirs() -> list[str]: ...
2124
def getdoc(object: object) -> str: ...
2225
def splitdoc(doc: AnyStr) -> tuple[AnyStr, AnyStr]: ...
@@ -229,16 +232,36 @@ class TextDoc(Doc):
229232
doc: Any | None = None,
230233
) -> str: ...
231234

232-
def pager(text: str) -> None: ...
233-
def getpager() -> Callable[[str], None]: ...
235+
if sys.version_info >= (3, 13):
236+
def pager(text: str, title: str = "") -> None: ...
237+
238+
else:
239+
def pager(text: str) -> None: ...
240+
234241
def plain(text: str) -> str: ...
235-
def pipepager(text: str, cmd: str) -> None: ...
236-
def tempfilepager(text: str, cmd: str) -> None: ...
237-
def ttypager(text: str) -> None: ...
238-
def plainpager(text: str) -> None: ...
239242
def describe(thing: Any) -> str: ...
240243
def locate(path: str, forceload: bool = ...) -> object: ...
241244

245+
if sys.version_info >= (3, 13):
246+
def get_pager() -> _Pager: ...
247+
def pipe_pager(text: str, cmd: str, title: str = "") -> None: ...
248+
def tempfile_pager(text: str, cmd: str, title: str = "") -> None: ...
249+
def tty_pager(text: str, title: str = "") -> None: ...
250+
def plain_pager(text: str, title: str = "") -> None: ...
251+
252+
# For backwards compatibility.
253+
getpager = get_pager
254+
pipepager = pipe_pager
255+
tempfilepager = tempfile_pager
256+
ttypager = tty_pager
257+
plainpager = plain_pager
258+
else:
259+
def getpager() -> Callable[[str], None]: ...
260+
def pipepager(text: str, cmd: str) -> None: ...
261+
def tempfilepager(text: str, cmd: str) -> None: ...
262+
def ttypager(text: str) -> None: ...
263+
def plainpager(text: str) -> None: ...
264+
242265
text: TextDoc
243266
html: HTMLDoc
244267

0 commit comments

Comments
 (0)