Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions stdlib/fileinput.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
import sys
from _typeshed import StrOrBytesPath
from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Optional, Union
from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Union

if sys.version_info >= (3, 8):
if sys.version_info >= (3, 10):
def input(
files: Union[StrOrBytesPath, Iterable[StrOrBytesPath], None] = ...,
inplace: bool = ...,
backup: str = ...,
*,
mode: str = ...,
openhook: Callable[[StrOrBytesPath, str], IO[AnyStr]] = ...,
encoding: str | None = ...,
errors: str | None = ...,
) -> FileInput[AnyStr]: ...

elif sys.version_info >= (3, 8):
def input(
files: Union[StrOrBytesPath, Iterable[StrOrBytesPath], None] = ...,
inplace: bool = ...,
Expand Down Expand Up @@ -32,7 +44,19 @@ def isfirstline() -> bool: ...
def isstdin() -> bool: ...

class FileInput(Iterable[AnyStr], Generic[AnyStr]):
if sys.version_info >= (3, 8):
if sys.version_info >= (3, 10):
def __init__(
self,
files: Union[None, StrOrBytesPath, Iterable[StrOrBytesPath]] = ...,
inplace: bool = ...,
backup: str = ...,
*,
mode: str = ...,
openhook: Callable[[StrOrBytesPath, str], IO[AnyStr]] = ...,
encoding: str | None = ...,
errors: str | None = ...,
) -> None: ...
elif sys.version_info >= (3, 8):
def __init__(
self,
files: Union[None, StrOrBytesPath, Iterable[StrOrBytesPath]] = ...,
Expand Down Expand Up @@ -68,5 +92,12 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]):
def isfirstline(self) -> bool: ...
def isstdin(self) -> bool: ...

def hook_compressed(filename: StrOrBytesPath, mode: str) -> IO[Any]: ...
def hook_encoded(encoding: str, errors: Optional[str] = ...) -> Callable[[StrOrBytesPath, str], IO[Any]]: ...
if sys.version_info >= (3, 10):
def hook_compressed(
filename: StrOrBytesPath, mode: str, *, encoding: str | None = ..., errors: str | None = ...
) -> IO[Any]: ...

else:
def hook_compressed(filename: StrOrBytesPath, mode: str) -> IO[Any]: ...

def hook_encoded(encoding: str, errors: str | None = ...) -> Callable[[StrOrBytesPath, str], IO[Any]]: ...