Skip to content
This repository has been archived by the owner on Dec 27, 2021. It is now read-only.

Commit

Permalink
Drop support for Python 3.5 (python#4675)
Browse files Browse the repository at this point in the history
Python 3.5 EOL was on 2020-09-30.
  • Loading branch information
srittau authored Nov 2, 2020
1 parent 57b86e0 commit d2a7889
Show file tree
Hide file tree
Showing 64 changed files with 547 additions and 1,175 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/stubtest-unused-whitelist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8, 3.9]
fail-fast: false

steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
python-version: [3.6, 3.7, 3.8, 3.9]
fail-fast: false

steps:
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contributors can be found in [CONTRIBUTING.md](CONTRIBUTING.md). **Please read
it before submitting pull requests; do not report issues with annotations to
the project the stubs are for, but instead report them here to typeshed.**

Typeshed supports Python versions 2.7 and 3.5 and up.
Typeshed supports Python versions 2.7 and 3.6 and up.

## Using

Expand Down Expand Up @@ -124,7 +124,7 @@ typed-ast, flake8 (and plugins), pytype, black and isort.

### mypy_test.py

This test requires Python 3.5 or higher; Python 3.6.1 or higher is recommended.
This test requires Python 3.6 or higher; Python 3.6.1 or higher is recommended.
Run using:`(.venv3)$ python3 tests/mypy_test.py`

This test is shallow — it verifies that all stubs can be
Expand All @@ -138,10 +138,10 @@ the mypy tests that avoids installing mypy:
```bash
$ PYTHONPATH=../.. python3 tests/mypy_test.py
```
You can restrict mypy tests to a single version by passing `-p2` or `-p3.5`:
You can restrict mypy tests to a single version by passing `-p2` or `-p3.9`:
```bash
$ PYTHONPATH=../.. python3 tests/mypy_test.py -p3.5
running mypy --python-version 3.5 --strict-optional # with 342 files
$ PYTHONPATH=../.. python3 tests/mypy_test.py -p3.9
running mypy --python-version 3.9 --strict-optional # with 342 files
```

### pytype_test.py
Expand All @@ -155,7 +155,7 @@ This test works similarly to `mypy_test.py`, except it uses `pytype`.

### mypy_selftest.py

This test requires Python 3.5 or higher; Python 3.6.1 or higher is recommended.
This test requires Python 3.6 or higher; Python 3.6.1 or higher is recommended.
Run using: `(.venv3)$ python3 tests/mypy_selftest.py`

This test checks mypy's code base using mypy and typeshed code in this repo.
Expand All @@ -175,7 +175,7 @@ Run using: `python3 tests/check_consistent.py`

### stubtest_test.py

This test requires Python 3.5 or higher.
This test requires Python 3.6 or higher.
Run using `(.venv3)$ python3 tests/stubtest_test.py`

This test compares the stdlib stubs against the objects at runtime. Because of
Expand Down
4 changes: 2 additions & 2 deletions scripts/migrate_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
STDLIB_NAMESPACE = "stdlib"
THIRD_PARTY_NAMESPACE = "stubs"
DEFAULT_VERSION = "0.1"
DEFAULT_PY3_VERSION = "3.5"
DEFAULT_PY3_VERSION = "3.6"
PY2_NAMESPACE = "python2"
OUTPUT_DIR = "out"

Expand Down Expand Up @@ -113,7 +113,7 @@ def collect_stdlib_packages() -> Tuple[List[StdLibPackage], List[StdLibPackage]]
add_stdlib_packages_from("stdlib/2and3", stdlib, "2.7")
# Use oldest currently supported version for Python 3 packages/modules.
add_stdlib_packages_from("stdlib/3", stdlib, DEFAULT_PY3_VERSION)
for version in ("3.6", "3.7", "3.8", "3.9"):
for version in ("3.7", "3.8", "3.9"):
subdir = os.path.join("stdlib", version)
if os.path.isdir(subdir):
add_stdlib_packages_from(subdir, stdlib, version)
Expand Down
41 changes: 19 additions & 22 deletions stdlib/3/_ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,11 @@ class AugAssign(stmt):
op: operator
value: expr

if sys.version_info >= (3, 6):
class AnnAssign(stmt):
target: expr
annotation: expr
value: Optional[expr]
simple: int
class AnnAssign(stmt):
target: expr
annotation: expr
value: Optional[expr]
simple: int

class For(stmt):
target: expr
Expand Down Expand Up @@ -225,13 +224,13 @@ class Call(expr):
args: typing.List[expr]
keywords: typing.List[keyword]

if sys.version_info >= (3, 6):
class FormattedValue(expr):
value: expr
conversion: Optional[int]
format_spec: Optional[expr]
class JoinedStr(expr):
values: typing.List[expr]
class FormattedValue(expr):
value: expr
conversion: Optional[int]
format_spec: Optional[expr]

class JoinedStr(expr):
values: typing.List[expr]

if sys.version_info < (3, 8):
class Num(expr): # Deprecated in 3.8; use Constant
Expand All @@ -244,13 +243,12 @@ if sys.version_info < (3, 8):
value: Any
class Ellipsis(expr): ... # Deprecated in 3.8; use Constant

if sys.version_info >= (3, 6):
class Constant(expr):
value: Any # None, str, bytes, bool, int, float, complex, Ellipsis
kind: Optional[str]
# Aliases for value, for backwards compatibility
s: Any
n: complex
class Constant(expr):
value: Any # None, str, bytes, bool, int, float, complex, Ellipsis
kind: Optional[str]
# Aliases for value, for backwards compatibility
s: Any
n: complex

if sys.version_info >= (3, 8):
class NamedExpr(expr):
Expand Down Expand Up @@ -350,8 +348,7 @@ class comprehension(AST):
target: expr
iter: expr
ifs: typing.List[expr]
if sys.version_info >= (3, 6):
is_async: int
is_async: int

class excepthandler(AST): ...

Expand Down
5 changes: 1 addition & 4 deletions stdlib/3/_compat_pickle.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
from typing import Dict, Tuple

IMPORT_MAPPING: Dict[str, str]
Expand All @@ -8,6 +7,4 @@ MULTIPROCESSING_EXCEPTIONS: Tuple[str, ...]
REVERSE_IMPORT_MAPPING: Dict[str, str]
REVERSE_NAME_MAPPING: Dict[Tuple[str, str], Tuple[str, str]]
PYTHON3_OSERROR_EXCEPTIONS: Tuple[str, ...]

if sys.version_info >= (3, 6):
PYTHON3_IMPORTERROR_EXCEPTIONS: Tuple[str, ...]
PYTHON3_IMPORTERROR_EXCEPTIONS: Tuple[str, ...]
11 changes: 4 additions & 7 deletions stdlib/3/ast.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class NodeVisitor:
def visit_Delete(self, node: Delete) -> Any: ...
def visit_Assign(self, node: Assign) -> Any: ...
def visit_AugAssign(self, node: AugAssign) -> Any: ...
if sys.version_info >= (3, 6):
def visit_AnnAssign(self, node: AnnAssign) -> Any: ...
def visit_AnnAssign(self, node: AnnAssign) -> Any: ...
def visit_For(self, node: For) -> Any: ...
def visit_AsyncFor(self, node: AsyncFor) -> Any: ...
def visit_While(self, node: While) -> Any: ...
Expand Down Expand Up @@ -85,11 +84,9 @@ class NodeVisitor:
def visit_YieldFrom(self, node: YieldFrom) -> Any: ...
def visit_Compare(self, node: Compare) -> Any: ...
def visit_Call(self, node: Call) -> Any: ...
if sys.version_info >= (3, 6):
def visit_FormattedValue(self, node: FormattedValue) -> Any: ...
def visit_JoinedStr(self, node: JoinedStr) -> Any: ...
if sys.version_info >= (3, 6):
def visit_Constant(self, node: Constant) -> Any: ...
def visit_FormattedValue(self, node: FormattedValue) -> Any: ...
def visit_JoinedStr(self, node: JoinedStr) -> Any: ...
def visit_Constant(self, node: Constant) -> Any: ...
if sys.version_info >= (3, 8):
def visit_NamedExpr(self, node: NamedExpr) -> Any: ...
def visit_Attribute(self, node: Attribute) -> Any: ...
Expand Down
3 changes: 1 addition & 2 deletions stdlib/3/asyncio/base_events.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ class BaseEventLoop(AbstractEventLoop, metaclass=ABCMeta):
def is_running(self) -> bool: ...
def is_closed(self) -> bool: ...
def close(self) -> None: ...
if sys.version_info >= (3, 6):
async def shutdown_asyncgens(self) -> None: ...
async def shutdown_asyncgens(self) -> None: ...
# Methods scheduling callbacks. All these return Handles.
if sys.version_info >= (3, 7):
def call_soon(self, callback: Callable[..., Any], *args: Any, context: Optional[Context] = ...) -> Handle: ...
Expand Down
3 changes: 1 addition & 2 deletions stdlib/3/asyncio/constants.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import sys

LOG_THRESHOLD_FOR_CONNLOST_WRITES: int
ACCEPT_RETRY_DELAY: int
if sys.version_info >= (3, 6):
DEBUG_STACK_DEPTH: int
DEBUG_STACK_DEPTH: int
if sys.version_info >= (3, 7):
SSL_HANDSHAKE_TIMEOUT: float
SENDFILE_FALLBACK_READBUFFER_SIZE: int
Expand Down
2 changes: 0 additions & 2 deletions stdlib/3/asyncio/futures.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ class Future(Awaitable[_T], Iterable[_T]):
_exception: BaseException
_blocking = False
_log_traceback = False
if sys.version_info < (3, 6):
_tb_logger: Type[_TracebackLogger]
def __init__(self, *, loop: Optional[AbstractEventLoop] = ...) -> None: ...
def __repr__(self) -> str: ...
def __del__(self) -> None: ...
Expand Down
8 changes: 1 addition & 7 deletions stdlib/3/asyncio/sslproto.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ class _SSLProtocolTransport(transports._FlowControlMixin, transports.Transport):
_loop: events.AbstractEventLoop
_ssl_protocol: SSLProtocol
_closed: bool

if sys.version_info >= (3, 6):
def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol) -> None: ...
else:
def __init__(
self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol, app_protocol: protocols.BaseProtocol
) -> None: ...
def __init__(self, loop: events.AbstractEventLoop, ssl_protocol: SSLProtocol) -> None: ...
def get_extra_info(self, name: str, default: Optional[Any] = ...) -> Dict[str, Any]: ...
def set_protocol(self, protocol: protocols.BaseProtocol) -> None: ...
def get_protocol(self) -> protocols.BaseProtocol: ...
Expand Down
5 changes: 2 additions & 3 deletions stdlib/3/asyncio/transports.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ class BaseTransport:
def get_extra_info(self, name: Any, default: Any = ...) -> Any: ...
def is_closing(self) -> bool: ...
def close(self) -> None: ...
if sys.version_info >= (3, 5):
def set_protocol(self, protocol: BaseProtocol) -> None: ...
def get_protocol(self) -> BaseProtocol: ...
def set_protocol(self, protocol: BaseProtocol) -> None: ...
def get_protocol(self) -> BaseProtocol: ...

class ReadTransport(BaseTransport):
if sys.version_info >= (3, 7):
Expand Down
11 changes: 4 additions & 7 deletions stdlib/3/builtins.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ class object:
__dict__: Dict[str, Any]
__slots__: Union[str, Iterable[str]]
__module__: str
if sys.version_info >= (3, 6):
__annotations__: Dict[str, Any]
__annotations__: Dict[str, Any]
@property
def __class__(self: _T) -> Type[_T]: ...
@__class__.setter
Expand All @@ -106,8 +105,7 @@ class object:
def __reduce__(self) -> Union[str, Tuple[Any, ...]]: ...
def __reduce_ex__(self, protocol: int) -> Union[str, Tuple[Any, ...]]: ...
def __dir__(self) -> Iterable[str]: ...
if sys.version_info >= (3, 6):
def __init_subclass__(cls) -> None: ...
def __init_subclass__(cls) -> None: ...

class staticmethod(object): # Special, only valid as a decorator.
__func__: Callable[..., Any]
Expand Down Expand Up @@ -422,7 +420,7 @@ class bytes(ByteString):
def find(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ...
if sys.version_info >= (3, 8):
def hex(self, sep: Union[str, bytes] = ..., bytes_per_sep: int = ...) -> str: ...
elif sys.version_info >= (3, 5):
else:
def hex(self) -> str: ...
def index(self, sub: Union[bytes, int], start: Optional[int] = ..., end: Optional[int] = ...) -> int: ...
def isalnum(self) -> bool: ...
Expand Down Expand Up @@ -478,8 +476,7 @@ class bytes(ByteString):
def __add__(self, s: bytes) -> bytes: ...
def __mul__(self, n: int) -> bytes: ...
def __rmul__(self, n: int) -> bytes: ...
if sys.version_info >= (3, 5):
def __mod__(self, value: Any) -> bytes: ...
def __mod__(self, value: Any) -> bytes: ...
# Incompatible with Sequence.__contains__
def __contains__(self, o: Union[int, bytes]) -> bool: ... # type: ignore
def __eq__(self, x: object) -> bool: ...
Expand Down
15 changes: 3 additions & 12 deletions stdlib/3/collections/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import typing
from typing import (
AbstractSet,
Any,
AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable,
AsyncIterator as AsyncIterator,
Awaitable as Awaitable,
ByteString as ByteString,
Callable as Callable,
Collection as Collection,
Container as Container,
Coroutine as Coroutine,
Dict,
Expand Down Expand Up @@ -38,9 +40,6 @@ from typing import (

Set = AbstractSet

if sys.version_info >= (3, 6):
from typing import AsyncGenerator as AsyncGenerator, Collection as Collection

_S = TypeVar("_S")
_T = TypeVar("_T")
_KT = TypeVar("_KT")
Expand All @@ -57,7 +56,7 @@ if sys.version_info >= (3, 7):
defaults: Optional[Iterable[Any]] = ...,
) -> Type[Tuple[Any, ...]]: ...

elif sys.version_info >= (3, 6):
else:
def namedtuple(
typename: str,
field_names: Union[str, Iterable[str]],
Expand All @@ -67,11 +66,6 @@ elif sys.version_info >= (3, 6):
module: Optional[str] = ...,
) -> Type[Tuple[Any, ...]]: ...

else:
def namedtuple(
typename: str, field_names: Union[str, Iterable[str]], verbose: bool = ..., rename: bool = ...
) -> Type[Tuple[Any, ...]]: ...

class UserDict(MutableMapping[_KT, _VT]):
data: Dict[_KT, _VT]
def __init__(self, __dict: Optional[Mapping[_KT, _VT]] = ..., **kwargs: _VT) -> None: ...
Expand Down Expand Up @@ -194,9 +188,6 @@ class UserString(Sequence[str]):
def upper(self: _UserStringT) -> _UserStringT: ...
def zfill(self: _UserStringT, width: int) -> _UserStringT: ...

# Technically, deque only derives from MutableSequence in 3.5 (before then, the insert and index
# methods did not exist).
# But in practice it's not worth losing sleep over.
class deque(MutableSequence[_T], Generic[_T]):
@property
def maxlen(self) -> Optional[int]: ...
Expand Down
8 changes: 3 additions & 5 deletions stdlib/3/collections/abc.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import sys

from . import (
AsyncGenerator as AsyncGenerator,
AsyncIterable as AsyncIterable,
AsyncIterator as AsyncIterator,
Awaitable as Awaitable,
ByteString as ByteString,
Callable as Callable,
Collection as Collection,
Container as Container,
Coroutine as Coroutine,
Generator as Generator,
Expand All @@ -19,11 +19,9 @@ from . import (
MutableMapping as MutableMapping,
MutableSequence as MutableSequence,
MutableSet as MutableSet,
Reversible as Reversible,
Sequence as Sequence,
Set as Set,
Sized as Sized,
ValuesView as ValuesView,
)

if sys.version_info >= (3, 6):
from . import AsyncGenerator as AsyncGenerator, Collection as Collection, Reversible as Reversible
Loading

0 comments on commit d2a7889

Please sign in to comment.