comparison mercurial/utils/stringutil.py @ 52709:279e217d6041

typing: lock in the new type annotations detected with the pyupgrade changes After the changes culminating in 70a75d379daf, pytype was able to detect these types better (typically changing from something like `Generator[Any, Any, None]` to `Generator[bytes, Any, None]`). Let's make these explicit so they don't disappear because of other changes.
author Matt Harbison <matt_harbison@yahoo.com>
date Mon, 06 Jan 2025 20:02:17 -0500
parents e627cc25b6f3
children
comparison
equal deleted inserted replaced
52708:efac197c6cff 52709:279e217d6041
15 import textwrap 15 import textwrap
16 import types 16 import types
17 import typing 17 import typing
18 18
19 from typing import ( 19 from typing import (
20 Iterator,
20 Optional, 21 Optional,
21 overload, 22 overload,
22 ) 23 )
23 24
24 from ..i18n import _ 25 from ..i18n import _
70 def pprint(o, bprefix: bool = False, indent: int = 0, level: int = 0) -> bytes: 71 def pprint(o, bprefix: bool = False, indent: int = 0, level: int = 0) -> bytes:
71 """Pretty print an object.""" 72 """Pretty print an object."""
72 return b''.join(pprintgen(o, bprefix=bprefix, indent=indent, level=level)) 73 return b''.join(pprintgen(o, bprefix=bprefix, indent=indent, level=level))
73 74
74 75
75 def pprintgen(o, bprefix: bool = False, indent: int = 0, level: int = 0): 76 def pprintgen(
77 o, bprefix: bool = False, indent: int = 0, level: int = 0
78 ) -> Iterator[bytes]:
76 """Pretty print an object to a generator of atoms. 79 """Pretty print an object to a generator of atoms.
77 80
78 ``bprefix`` is a flag influencing whether bytestrings are preferred with 81 ``bprefix`` is a flag influencing whether bytestrings are preferred with
79 a ``b''`` prefix. 82 a ``b''`` prefix.
80 83