1111)
1212import sys
1313from typing import (
14+ TYPE_CHECKING ,
1415 Any ,
1516 Callable ,
1617 TypeVar ,
2425
2526from pandas .io .formats .console import get_console_size
2627
28+ if TYPE_CHECKING :
29+ from pandas ._typing import ListLike
2730EscapeChars = Union [Mapping [str , str ], Iterable [str ]]
2831_KT = TypeVar ("_KT" )
2932_VT = TypeVar ("_VT" )
3033
3134
32- def adjoin (space : int , * lists : list [str ], ** kwargs ) -> str :
35+ def adjoin (space : int , * lists : list [str ], ** kwargs : Any ) -> str :
3336 """
3437 Glues together two sets of strings using the amount of space requested.
3538 The idea is to prettify.
@@ -98,7 +101,7 @@ def _adj_justify(texts: Iterable[str], max_len: int, mode: str = "right") -> lis
98101
99102
100103def _pprint_seq (
101- seq : Sequence , _nest_lvl : int = 0 , max_seq_items : int | None = None , ** kwds
104+ seq : ListLike , _nest_lvl : int = 0 , max_seq_items : int | None = None , ** kwds : Any
102105) -> str :
103106 """
104107 internal. pprinter for iterables. you should probably use pprint_thing()
@@ -136,7 +139,7 @@ def _pprint_seq(
136139
137140
138141def _pprint_dict (
139- seq : Mapping , _nest_lvl : int = 0 , max_seq_items : int | None = None , ** kwds
142+ seq : Mapping , _nest_lvl : int = 0 , max_seq_items : int | None = None , ** kwds : Any
140143) -> str :
141144 """
142145 internal. pprinter for iterables. you should probably use pprint_thing()
@@ -167,7 +170,7 @@ def _pprint_dict(
167170
168171
169172def pprint_thing (
170- thing : Any ,
173+ thing : object ,
171174 _nest_lvl : int = 0 ,
172175 escape_chars : EscapeChars | None = None ,
173176 default_escapes : bool = False ,
@@ -225,7 +228,10 @@ def as_escaped_string(
225228 )
226229 elif is_sequence (thing ) and _nest_lvl < get_option ("display.pprint_nest_depth" ):
227230 result = _pprint_seq (
228- thing ,
231+ # error: Argument 1 to "_pprint_seq" has incompatible type "object";
232+ # expected "ExtensionArray | ndarray[Any, Any] | Index | Series |
233+ # SequenceNotStr[Any] | range"
234+ thing , # type: ignore[arg-type]
229235 _nest_lvl ,
230236 escape_chars = escape_chars ,
231237 quote_strings = quote_strings ,
@@ -240,7 +246,7 @@ def as_escaped_string(
240246
241247
242248def pprint_thing_encoded (
243- object , encoding : str = "utf-8" , errors : str = "replace"
249+ object : object , encoding : str = "utf-8" , errors : str = "replace"
244250) -> bytes :
245251 value = pprint_thing (object ) # get unicode representation of object
246252 return value .encode (encoding , errors )
@@ -252,7 +258,8 @@ def enable_data_resource_formatter(enable: bool) -> None:
252258 return
253259 from IPython import get_ipython
254260
255- ip = get_ipython ()
261+ # error: Call to untyped function "get_ipython" in typed context
262+ ip = get_ipython () # type: ignore[no-untyped-call]
256263 if ip is None :
257264 # still not in IPython
258265 return
@@ -289,7 +296,7 @@ def default_pprint(thing: Any, max_seq_items: int | None = None) -> str:
289296
290297
291298def format_object_summary (
292- obj ,
299+ obj : ListLike ,
293300 formatter : Callable ,
294301 is_justify : bool = True ,
295302 name : str | None = None ,
@@ -525,7 +532,7 @@ def justify(self, texts: Any, max_len: int, mode: str = "right") -> list[str]:
525532 else :
526533 return [x .rjust (max_len ) for x in texts ]
527534
528- def adjoin (self , space : int , * lists , ** kwargs ) -> str :
535+ def adjoin (self , space : int , * lists : Any , ** kwargs : Any ) -> str :
529536 return adjoin (space , * lists , strlen = self .len , justfunc = self .justify , ** kwargs )
530537
531538
@@ -557,7 +564,7 @@ def justify(
557564 self , texts : Iterable [str ], max_len : int , mode : str = "right"
558565 ) -> list [str ]:
559566 # re-calculate padding space per str considering East Asian Width
560- def _get_pad (t ) :
567+ def _get_pad (t : str ) -> int :
561568 return max_len - self .len (t ) + len (t )
562569
563570 if mode == "left" :
0 commit comments