Skip to content

Commit 0a666bd

Browse files
JelleZijlstraJiri Suchan
authored and
Jiri Suchan
committedJan 23, 2019
fix some abstract classes in Python 2 (python#2240)
Part of python#1476.
1 parent 2133f50 commit 0a666bd

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed
 

‎stdlib/2/__builtin__.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,7 @@ class file(BinaryIO):
10601060
@overload
10611061
def __init__(self, file: int, mode: str = ..., buffering: int = ...) -> None: ...
10621062
def __iter__(self) -> Iterator[str]: ...
1063+
def next(self) -> str: ...
10631064
def read(self, n: int = ...) -> str: ...
10641065
def __enter__(self) -> BinaryIO: ...
10651066
def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> bool: ...

‎stdlib/2/builtins.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,7 @@ class file(BinaryIO):
10601060
@overload
10611061
def __init__(self, file: int, mode: str = ..., buffering: int = ...) -> None: ...
10621062
def __iter__(self) -> Iterator[str]: ...
1063+
def next(self) -> str: ...
10631064
def read(self, n: int = ...) -> str: ...
10641065
def __enter__(self) -> BinaryIO: ...
10651066
def __exit__(self, t: Optional[type] = ..., exc: Optional[BaseException] = ..., tb: Optional[Any] = ...) -> bool: ...

‎stdlib/2/cStringIO.pyi

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
# Stubs for cStringIO (Python 2.7)
22
# See https://docs.python.org/2/library/stringio.html
33

4+
from abc import ABCMeta
45
from typing import overload, IO, List, Iterable, Iterator, Optional, Union
56
from types import TracebackType
67

78
# TODO the typing.IO[] generics should be split into input and output.
89

9-
class InputType(IO[str], Iterator[str]):
10+
# This class isn't actually abstract, but you can't instantiate it
11+
# directly, so we might as well treat it as abstract in the stub.
12+
class InputType(IO[str], Iterator[str], metaclass=ABCMeta):
1013
def getvalue(self) -> str: ...
1114
def close(self) -> None: ...
1215
@property
@@ -23,7 +26,8 @@ class InputType(IO[str], Iterator[str]):
2326
def next(self) -> str: ...
2427
def reset(self) -> None: ...
2528

26-
class OutputType(IO[str], Iterator[str]):
29+
30+
class OutputType(IO[str], Iterator[str], metaclass=ABCMeta):
2731
@property
2832
def softspace(self) -> int: ...
2933
def getvalue(self) -> str: ...

‎stdlib/2/typing.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ class TextIO(IO[unicode]):
348348
@abstractmethod
349349
def __enter__(self) -> TextIO: ...
350350

351-
class ByteString(Sequence[int]): ...
351+
class ByteString(Sequence[int], metaclass=ABCMeta): ...
352352

353353
class Match(Generic[AnyStr]):
354354
pos = 0

‎third_party/2/enum.pyi

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class EnumMeta(ABCMeta, Iterable[Enum], Sized, Reversible[Enum], Container[Enum]
1515
def __getitem__(self: Type[_T], name: str) -> _T: ...
1616
@property
1717
def __members__(self: Type[_T]) -> Mapping[str, _T]: ...
18+
def __len__(self) -> int: ...
1819

1920
class Enum(metaclass=EnumMeta):
2021
def __new__(cls: Type[_T], value: Any) -> _T: ...

0 commit comments

Comments
 (0)
Please sign in to comment.