|
2 | 2 | # (https://github.com/python/cpython/) at commit
|
3 | 3 | # c5140945c723ae6c4b7ee81ff720ac8ea4b52cfd (python3.12).
|
4 | 4 | #
|
5 |
| -# flake8: noqa |
6 |
| -# type: ignore |
7 |
| -# |
8 | 5 | #
|
9 | 6 | # Original Author: Fred L. Drake, Jr.
|
10 | 7 |
|
|
21 | 18 | import sys as _sys
|
22 | 19 | import types as _types
|
23 | 20 | from io import StringIO as _StringIO
|
| 21 | +from typing import Any |
| 22 | +from typing import Callable |
| 23 | +from typing import Dict |
| 24 | +from typing import IO |
| 25 | +from typing import List |
24 | 26 |
|
25 | 27 |
|
26 | 28 | class _safe_key:
|
@@ -49,7 +51,7 @@ def __lt__(self, other):
|
49 | 51 |
|
50 | 52 |
|
51 | 53 | def _safe_tuple(t):
|
52 |
| - "Helper function for comparing 2-tuples" |
| 54 | + """Helper function for comparing 2-tuples""" |
53 | 55 | return _safe_key(t[0]), _safe_key(t[1])
|
54 | 56 |
|
55 | 57 |
|
@@ -107,7 +109,7 @@ def __init__(
|
107 | 109 | self._sort_dicts = sort_dicts
|
108 | 110 | self._underscore_numbers = underscore_numbers
|
109 | 111 |
|
110 |
| - def pformat(self, object): |
| 112 | + def pformat(self, object: Any) -> str: |
111 | 113 | sio = _StringIO()
|
112 | 114 | self._format(object, sio, 0, 0, {}, 0)
|
113 | 115 | return sio.getvalue()
|
@@ -157,7 +159,10 @@ def _pprint_dataclass(self, object, stream, indent, allowance, context, level):
|
157 | 159 | self._format_namespace_items(items, stream, indent, allowance, context, level)
|
158 | 160 | stream.write(")")
|
159 | 161 |
|
160 |
| - _dispatch = {} |
| 162 | + _dispatch: Dict[ |
| 163 | + Callable[..., str], |
| 164 | + Callable[["PrettyPrinter", Any, IO[str], int, int, Dict[int, int], int], str], |
| 165 | + ] = {} |
161 | 166 |
|
162 | 167 | def _pprint_dict(self, object, stream, indent, allowance, context, level):
|
163 | 168 | write = stream.write
|
@@ -544,7 +549,7 @@ def _safe_repr(self, object, context, maxlevels, level):
|
544 | 549 | context[objid] = 1
|
545 | 550 | readable = True
|
546 | 551 | recursive = False
|
547 |
| - components = [] |
| 552 | + components: List[str] = [] |
548 | 553 | append = components.append
|
549 | 554 | level += 1
|
550 | 555 | if self._sort_dicts:
|
|
0 commit comments