Skip to content

clean old version checks from stdlib python3 stubs #5458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
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
6 changes: 2 additions & 4 deletions stdlib/__future__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@ nested_scopes: _Feature
print_function: _Feature
unicode_literals: _Feature
with_statement: _Feature
if sys.version_info >= (3, 0):
barry_as_FLUFL: _Feature
barry_as_FLUFL: _Feature

if sys.version_info >= (3, 5):
generator_stop: _Feature
generator_stop: _Feature

if sys.version_info >= (3, 7):
annotations: _Feature
Expand Down
23 changes: 6 additions & 17 deletions stdlib/_codecs.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,8 @@ from typing import Any, Callable, Dict, Optional, Text, Tuple, Union
_Handler = Callable[[Exception], Tuple[Text, int]]
_String = Union[bytes, str]
_Errors = Union[str, Text, None]
if sys.version_info >= (3, 0):
_Decodable = bytes
_Encodable = str
else:
_Decodable = Union[bytes, Text]
_Encodable = Union[bytes, Text]

_Decodable = bytes
_Encodable = str
# This type is not exposed; it is defined in unicodeobject.c
class _EncodingMap(object):
def size(self) -> int: ...
Expand All @@ -28,10 +23,6 @@ def encode(obj: Any, encoding: Union[str, Text] = ..., errors: _Errors = ...) ->
def charmap_build(__map: Text) -> _MapT: ...
def ascii_decode(__data: _Decodable, __errors: _Errors = ...) -> Tuple[Text, int]: ...
def ascii_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...

if sys.version_info < (3, 2):
def charbuffer_encode(__data: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...

def charmap_decode(__data: _Decodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[Text, int]: ...
def charmap_encode(__str: _Encodable, __errors: _Errors = ..., __mapping: Optional[_MapT] = ...) -> Tuple[bytes, int]: ...
def escape_decode(__data: _String, __errors: _Errors = ...) -> Tuple[str, int]: ...
Expand Down Expand Up @@ -74,9 +65,7 @@ def utf_8_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int
if sys.platform == "win32":
def mbcs_decode(__data: _Decodable, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def mbcs_encode(__str: _Encodable, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
if sys.version_info >= (3, 0):
def code_page_decode(__codepage: int, __data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def code_page_encode(__code_page: int, __str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
if sys.version_info >= (3, 6):
def oem_decode(__data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def oem_encode(__str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
def code_page_decode(__codepage: int, __data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def code_page_encode(__code_page: int, __str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
def oem_decode(__data: bytes, __errors: _Errors = ..., __final: int = ...) -> Tuple[Text, int]: ...
def oem_encode(__str: Text, __errors: _Errors = ...) -> Tuple[bytes, int]: ...
17 changes: 4 additions & 13 deletions stdlib/_csv.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
from typing import Any, Iterable, Iterator, List, Optional, Protocol, Sequence, Text, Type, Union
from typing import Any, Iterable, Iterator, List, Optional, Protocol, Text, Type, Union

QUOTE_ALL: int
QUOTE_MINIMAL: int
Expand All @@ -24,20 +23,12 @@ _DialectLike = Union[str, Dialect, Type[Dialect]]
class _reader(Iterator[List[str]]):
dialect: Dialect
line_num: int
if sys.version_info >= (3, 0):
def __next__(self) -> List[str]: ...
else:
def next(self) -> List[str]: ...
def __next__(self) -> List[str]: ...

class _writer:
dialect: Dialect

if sys.version_info >= (3, 5):
def writerow(self, row: Iterable[Any]) -> Any: ...
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...
else:
def writerow(self, row: Sequence[Any]) -> Any: ...
def writerows(self, rows: Iterable[Sequence[Any]]) -> None: ...
def writerow(self, row: Iterable[Any]) -> Any: ...
def writerows(self, rows: Iterable[Iterable[Any]]) -> None: ...

class _Writer(Protocol):
def write(self, s: str) -> Any: ...
Expand Down
22 changes: 7 additions & 15 deletions stdlib/_curses.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -348,24 +348,17 @@ def tparm(
) -> bytes: ...
def typeahead(__fd: int) -> None: ...
def unctrl(__ch: _chtype) -> bytes: ...

if sys.version_info >= (3, 3):
def unget_wch(__ch: Union[int, str]) -> None: ...

def unget_wch(__ch: Union[int, str]) -> None: ...
def ungetch(__ch: _chtype) -> None: ...
def ungetmouse(__id: int, __x: int, __y: int, __z: int, __bstate: int) -> None: ...

if sys.version_info >= (3, 5):
def update_lines_cols() -> int: ...

def update_lines_cols() -> int: ...
def use_default_colors() -> None: ...
def use_env(__flag: bool) -> None: ...

class error(Exception): ...

class _CursesWindow:
if sys.version_info >= (3, 3):
encoding: str
encoding: str
@overload
def addch(self, ch: _chtype, attr: int = ...) -> None: ...
@overload
Expand Down Expand Up @@ -429,11 +422,10 @@ class _CursesWindow:
def getch(self) -> int: ...
@overload
def getch(self, y: int, x: int) -> int: ...
if sys.version_info >= (3, 3):
@overload
def get_wch(self) -> Union[int, str]: ...
@overload
def get_wch(self, y: int, x: int) -> Union[int, str]: ...
@overload
def get_wch(self) -> Union[int, str]: ...
@overload
def get_wch(self, y: int, x: int) -> Union[int, str]: ...
@overload
def getkey(self) -> str: ...
@overload
Expand Down
113 changes: 36 additions & 77 deletions stdlib/_dummy_threading.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,11 @@ _T = TypeVar("_T")
__all__: List[str]

def active_count() -> int: ...

if sys.version_info < (3,):
def activeCount() -> int: ...

def current_thread() -> Thread: ...
def currentThread() -> Thread: ...

if sys.version_info >= (3,):
def get_ident() -> int: ...

def get_ident() -> int: ...
def enumerate() -> List[Thread]: ...

if sys.version_info >= (3, 4):
def main_thread() -> Thread: ...
def main_thread() -> Thread: ...

if sys.version_info >= (3, 8):
from _thread import get_native_id as get_native_id
Expand All @@ -33,8 +24,7 @@ def settrace(func: _TF) -> None: ...
def setprofile(func: Optional[_PF]) -> None: ...
def stack_size(size: int = ...) -> int: ...

if sys.version_info >= (3,):
TIMEOUT_MAX: float
TIMEOUT_MAX: float

class ThreadError(Exception): ...

Expand All @@ -47,26 +37,16 @@ class Thread:
name: str
ident: Optional[int]
daemon: bool
if sys.version_info >= (3,):
def __init__(
self,
group: None = ...,
target: Optional[Callable[..., Any]] = ...,
name: Optional[str] = ...,
args: Iterable[Any] = ...,
kwargs: Optional[Mapping[str, Any]] = ...,
*,
daemon: Optional[bool] = ...,
) -> None: ...
else:
def __init__(
self,
group: None = ...,
target: Optional[Callable[..., Any]] = ...,
name: Optional[Text] = ...,
args: Iterable[Any] = ...,
kwargs: Optional[Mapping[Text, Any]] = ...,
) -> None: ...
def __init__(
self,
group: None = ...,
target: Optional[Callable[..., Any]] = ...,
name: Optional[str] = ...,
args: Iterable[Any] = ...,
kwargs: Optional[Mapping[str, Any]] = ...,
*,
daemon: Optional[bool] = ...,
) -> None: ...
def start(self) -> None: ...
def run(self) -> None: ...
def join(self, timeout: Optional[float] = ...) -> None: ...
Expand All @@ -89,10 +69,7 @@ class Lock:
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> Optional[bool]: ...
if sys.version_info >= (3,):
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
else:
def acquire(self, blocking: bool = ...) -> bool: ...
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
def release(self) -> None: ...
def locked(self) -> bool: ...

Expand All @@ -102,10 +79,7 @@ class _RLock:
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> Optional[bool]: ...
if sys.version_info >= (3,):
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
else:
def acquire(self, blocking: bool = ...) -> bool: ...
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
def release(self) -> None: ...

RLock = _RLock
Expand All @@ -116,14 +90,10 @@ class Condition:
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> Optional[bool]: ...
if sys.version_info >= (3,):
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
else:
def acquire(self, blocking: bool = ...) -> bool: ...
def acquire(self, blocking: bool = ..., timeout: float = ...) -> bool: ...
def release(self) -> None: ...
def wait(self, timeout: Optional[float] = ...) -> bool: ...
if sys.version_info >= (3,):
def wait_for(self, predicate: Callable[[], _T], timeout: Optional[float] = ...) -> _T: ...
def wait_for(self, predicate: Callable[[], _T], timeout: Optional[float] = ...) -> _T: ...
def notify(self, n: int = ...) -> None: ...
def notify_all(self) -> None: ...
def notifyAll(self) -> None: ...
Expand All @@ -133,12 +103,8 @@ class Semaphore:
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> Optional[bool]: ...
if sys.version_info >= (3,):
def acquire(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ...
def __enter__(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ...
else:
def acquire(self, blocking: bool = ...) -> bool: ...
def __enter__(self, blocking: bool = ...) -> bool: ...
def acquire(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ...
def __enter__(self, blocking: bool = ..., timeout: Optional[float] = ...) -> bool: ...
if sys.version_info >= (3, 9):
def release(self, n: int = ...) -> None: ...
else:
Expand All @@ -149,8 +115,6 @@ class BoundedSemaphore(Semaphore): ...
class Event:
def __init__(self) -> None: ...
def is_set(self) -> bool: ...
if sys.version_info < (3,):
def isSet(self) -> bool: ...
def set(self) -> None: ...
def clear(self) -> None: ...
def wait(self, timeout: Optional[float] = ...) -> bool: ...
Expand All @@ -162,27 +126,22 @@ if sys.version_info >= (3, 8):
ExceptHookArgs = _ExceptHookArgs

class Timer(Thread):
if sys.version_info >= (3,):
def __init__(
self,
interval: float,
function: Callable[..., Any],
args: Optional[Iterable[Any]] = ...,
kwargs: Optional[Mapping[str, Any]] = ...,
) -> None: ...
else:
def __init__(
self, interval: float, function: Callable[..., Any], args: Iterable[Any] = ..., kwargs: Mapping[str, Any] = ...
) -> None: ...
def __init__(
self,
interval: float,
function: Callable[..., Any],
args: Optional[Iterable[Any]] = ...,
kwargs: Optional[Mapping[str, Any]] = ...,
) -> None: ...
def cancel(self) -> None: ...

if sys.version_info >= (3,):
class Barrier:
parties: int
n_waiting: int
broken: bool
def __init__(self, parties: int, action: Optional[Callable[[], None]] = ..., timeout: Optional[float] = ...) -> None: ...
def wait(self, timeout: Optional[float] = ...) -> int: ...
def reset(self) -> None: ...
def abort(self) -> None: ...
class BrokenBarrierError(RuntimeError): ...
class Barrier:
parties: int
n_waiting: int
broken: bool
def __init__(self, parties: int, action: Optional[Callable[[], None]] = ..., timeout: Optional[float] = ...) -> None: ...
def wait(self, timeout: Optional[float] = ...) -> int: ...
def reset(self) -> None: ...
def abort(self) -> None: ...

class BrokenBarrierError(RuntimeError): ...
7 changes: 1 addition & 6 deletions stdlib/_heapq.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import sys
from typing import Any, Callable, Iterable, List, Optional, TypeVar
from typing import Any, List, TypeVar

_T = TypeVar("_T")

Expand All @@ -8,7 +7,3 @@ def heappop(__heap: List[_T]) -> _T: ...
def heappush(__heap: List[_T], __item: _T) -> None: ...
def heappushpop(__heap: List[_T], __item: _T) -> _T: ...
def heapreplace(__heap: List[_T], __item: _T) -> _T: ...

if sys.version_info < (3,):
def nlargest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ...
def nsmallest(__n: int, __iterable: Iterable[_T], __key: Optional[Callable[[_T], Any]] = ...) -> List[_T]: ...
3 changes: 0 additions & 3 deletions stdlib/_random.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
from typing import Tuple

# Actually Tuple[(int,) * 625]
Expand All @@ -11,5 +10,3 @@ class Random(object):
def setstate(self, __state: _State) -> None: ...
def random(self) -> float: ...
def getrandbits(self, __k: int) -> int: ...
if sys.version_info < (3,):
def jumpahead(self, i: int) -> None: ...
34 changes: 8 additions & 26 deletions stdlib/_typeshed/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
import array
import mmap
import sys
from typing import AbstractSet, Any, Container, Iterable, Protocol, Text, Tuple, TypeVar, Union
from os import PathLike
from typing import AbstractSet, Any, Container, Iterable, Protocol, Tuple, TypeVar, Union
from typing_extensions import Literal, final

_KT = TypeVar("_KT")
Expand All @@ -40,11 +41,7 @@ class SupportsRDivMod(Protocol[_T_contra, _T_co]):
# Mapping-like protocols

class SupportsItems(Protocol[_KT_co, _VT_co]):
if sys.version_info >= (3,):
def items(self) -> AbstractSet[Tuple[_KT_co, _VT_co]]: ...
else:
# We want dictionaries to support this on Python 2.
def items(self) -> Iterable[Tuple[_KT_co, _VT_co]]: ...
def items(self) -> AbstractSet[Tuple[_KT_co, _VT_co]]: ...

class SupportsKeysAndGetItem(Protocol[_KT, _VT_co]):
def keys(self) -> Iterable[_KT]: ...
Expand All @@ -57,19 +54,9 @@ class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra,
def __setitem__(self, __k: _KT_contra, __v: _VT) -> None: ...
def __delitem__(self, __v: _KT_contra) -> None: ...

# StrPath and AnyPath can be used in places where a
# path can be used instead of a string, starting with Python 3.6.
if sys.version_info >= (3, 6):
from os import PathLike

StrPath = Union[str, PathLike[str]]
BytesPath = Union[bytes, PathLike[bytes]]
AnyPath = Union[str, bytes, PathLike[str], PathLike[bytes]]
else:
StrPath = Text
BytesPath = bytes
AnyPath = Union[Text, bytes]

StrPath = Union[str, PathLike[str]]
BytesPath = Union[bytes, PathLike[bytes]]
AnyPath = Union[str, bytes, PathLike[str], PathLike[bytes]]
OpenTextModeUpdating = Literal[
"r+",
"+r",
Expand Down Expand Up @@ -155,13 +142,8 @@ class SupportsNoArgReadline(Protocol[_T_co]):
class SupportsWrite(Protocol[_T_contra]):
def write(self, __s: _T_contra) -> Any: ...

if sys.version_info >= (3,):
ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap]
WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap]
else:
ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap, buffer]
WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap, buffer]

ReadableBuffer = Union[bytes, bytearray, memoryview, array.array[Any], mmap.mmap]
WriteableBuffer = Union[bytearray, memoryview, array.array[Any], mmap.mmap]
if sys.version_info >= (3, 10):
from types import NoneType as NoneType
else:
Expand Down
Loading