11import collections .abc
22from collections .abc import Callable , Collection , Generator , Iterable , Iterator
33import contextlib
4- import io
54import os
65from pathlib import Path
76
@@ -12,7 +11,9 @@ from numpy.typing import ArrayLike
1211
1312from typing import (
1413 Any ,
14+ ContextManager ,
1515 Generic ,
16+ IO ,
1617 Literal ,
1718 TypeVar ,
1819 overload ,
@@ -42,35 +43,50 @@ class silent_list(list[_T]):
4243def strip_math (s : str ) -> str : ...
4344def is_writable_file_like (obj : Any ) -> bool : ...
4445def file_requires_unicode (x : Any ) -> bool : ...
46+ @overload
4547def to_filehandle (
46- fname : str | os .PathLike | io . FileIO ,
48+ fname : str | os .PathLike | IO ,
4749 flag : str = ...,
48- return_opened : bool = ...,
50+ return_opened : Literal [False ] = ...,
51+ encoding : str | None = ...,
52+ ) -> IO : ...
53+ @overload
54+ def to_filehandle (
55+ fname : str | os .PathLike | IO ,
56+ flag : str ,
57+ return_opened : Literal [True ],
58+ encoding : str | None = ...,
59+ ) -> tuple [IO , bool ]: ...
60+ @overload
61+ def to_filehandle (
62+ fname : str | os .PathLike | IO ,
63+ * , # if flag given, will match previous sig
64+ return_opened : Literal [True ],
4965 encoding : str | None = ...,
50- ) -> io . FileIO : ...
66+ ) -> tuple [ IO , bool ] : ...
5167def open_file_cm (
52- path_or_file : str | os .PathLike | io . FileIO ,
68+ path_or_file : str | os .PathLike | IO ,
5369 mode : str = ...,
5470 encoding : str | None = ...,
55- ): ...
71+ ) -> ContextManager [ IO ] : ...
5672def is_scalar_or_string (val : Any ) -> bool : ...
5773@overload
5874def get_sample_data (
59- fname : str | os .PathLike | io . FileIO ,
75+ fname : str | os .PathLike ,
6076 asfileobj : Literal [True ] = ...,
6177 * ,
6278 np_load : Literal [True ]
6379) -> np .ndarray : ...
6480@overload
6581def get_sample_data (
66- fname : str | os .PathLike | io . FileIO ,
82+ fname : str | os .PathLike ,
6783 asfileobj : Literal [True ] = ...,
6884 * ,
6985 np_load : Literal [False ] = ...
70- ) -> io . FileIO : ...
86+ ) -> IO : ...
7187@overload
7288def get_sample_data (
73- fname : str | os .PathLike | io . FileIO ,
89+ fname : str | os .PathLike ,
7490 asfileobj : Literal [False ],
7591 * ,
7692 np_load : bool = ...
@@ -96,7 +112,7 @@ class Stack(Generic[_T]):
96112
97113def safe_masked_invalid (x : ArrayLike , copy : bool = ...) -> np .ndarray : ...
98114def print_cycles (
99- objects : Iterable [Any ], outstream : io . FileIO = ..., show_progress : bool = ...
115+ objects : Iterable [Any ], outstream : IO = ..., show_progress : bool = ...
100116) -> None : ...
101117
102118class Grouper (Generic [_T ]):
0 commit comments