mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-30 08:04:24 +08:00
Add IO protocols to _typeshed (#4230)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from typing import Any, IO, Sequence, Tuple, Union, List, Dict, Protocol, Optional
|
||||
from typing import Any, IO, Sequence, Tuple, Union, List, Dict, Optional
|
||||
from _typeshed import SupportsReadline
|
||||
|
||||
DEFAULTSECT: str
|
||||
MAX_INTERPOLATION_DEPTH: int
|
||||
@@ -50,9 +51,6 @@ class MissingSectionHeaderError(ParsingError):
|
||||
line: Any
|
||||
def __init__(self, filename: str, lineno: Any, line: Any) -> None: ...
|
||||
|
||||
class _Readable(Protocol):
|
||||
def readline(self) -> str: ...
|
||||
|
||||
class RawConfigParser:
|
||||
_dict: Any
|
||||
_sections: Dict[Any, Any]
|
||||
@@ -68,7 +66,7 @@ class RawConfigParser:
|
||||
def has_section(self, section: str) -> bool: ...
|
||||
def options(self, section: str) -> List[str]: ...
|
||||
def read(self, filenames: Union[str, Sequence[str]]) -> List[str]: ...
|
||||
def readfp(self, fp: _Readable, filename: str = ...) -> None: ...
|
||||
def readfp(self, fp: SupportsReadline[str], filename: str = ...) -> None: ...
|
||||
def get(self, section: str, option: str) -> str: ...
|
||||
def items(self, section: str) -> List[Tuple[Any, Any]]: ...
|
||||
def _get(self, section: str, conv: type, option: str) -> Any: ...
|
||||
|
||||
@@ -15,7 +15,7 @@ from io import (
|
||||
TextIOWrapper, FileIO, BufferedRandom, BufferedReader, BufferedWriter
|
||||
)
|
||||
from types import TracebackType, CodeType
|
||||
from _typeshed import AnyPath, OpenBinaryMode, OpenTextMode, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenBinaryModeReading
|
||||
from _typeshed import AnyPath, OpenBinaryMode, OpenTextMode, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenBinaryModeReading, SupportsWrite
|
||||
from typing_extensions import Literal
|
||||
import sys
|
||||
|
||||
@@ -1480,17 +1480,13 @@ else:
|
||||
|
||||
def ord(__c: Union[Text, bytes]) -> int: ...
|
||||
if sys.version_info >= (3,):
|
||||
class _Writer(Protocol):
|
||||
def write(self, __s: str) -> Any: ...
|
||||
def print(
|
||||
*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ..., flush: bool = ...
|
||||
*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[SupportsWrite[str]] = ..., flush: bool = ...
|
||||
) -> None: ...
|
||||
|
||||
else:
|
||||
class _Writer(Protocol):
|
||||
def write(self, __s: Any) -> Any: ...
|
||||
# This is only available after from __future__ import print_function.
|
||||
def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[_Writer] = ...) -> None: ...
|
||||
def print(*values: object, sep: Optional[Text] = ..., end: Optional[Text] = ..., file: Optional[SupportsWrite[Any]] = ...) -> None: ...
|
||||
|
||||
_E = TypeVar("_E", contravariant=True)
|
||||
_M = TypeVar("_M", contravariant=True)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from typing import Any, IO, Optional, Tuple, Callable, Dict, List, Union, Text, Protocol, Type
|
||||
from typing import Any, IO, Optional, Tuple, Callable, Dict, List, Union, Text, Type
|
||||
from _typeshed import SupportsRead
|
||||
|
||||
class JSONDecodeError(ValueError):
|
||||
def dumps(self, obj: Any) -> str: ...
|
||||
@@ -43,10 +44,7 @@ def loads(s: Union[Text, bytes],
|
||||
object_pairs_hook: Optional[Callable[[List[Tuple[Any, Any]]], Any]] = ...,
|
||||
**kwds: Any) -> Any: ...
|
||||
|
||||
class _Reader(Protocol):
|
||||
def read(self) -> Union[Text, bytes]: ...
|
||||
|
||||
def load(fp: _Reader,
|
||||
def load(fp: SupportsRead[Union[Text, bytes]],
|
||||
encoding: Optional[str] = ...,
|
||||
cls: Optional[Type[JSONDecoder]] = ...,
|
||||
object_hook: Optional[Callable[[Dict[Any, Any]], Any]] = ...,
|
||||
|
||||
Reference in New Issue
Block a user