From a5d03e2496a392a2bc9ae2d4d0e74e49245d39c0 Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 6 Mar 2023 05:47:00 +0000 Subject: [PATCH] Remove compatibility branches in test fixtures for dead Python versions (#14839) --- test-data/unit/lib-stub/contextlib.pyi | 10 +- test-data/unit/lib-stub/mypy_extensions.pyi | 132 ++++++++++---------- 2 files changed, 67 insertions(+), 75 deletions(-) diff --git a/test-data/unit/lib-stub/contextlib.pyi b/test-data/unit/lib-stub/contextlib.pyi index e2a0cccd562a..ca9e91cf4d65 100644 --- a/test-data/unit/lib-stub/contextlib.pyi +++ b/test-data/unit/lib-stub/contextlib.pyi @@ -1,6 +1,5 @@ -import sys -from typing import Generic, TypeVar, Callable, Iterator -from typing import ContextManager as ContextManager +from typing import AsyncIterator, Generic, TypeVar, Callable, Iterator +from typing import ContextManager as ContextManager, AsyncContextManager as AsyncContextManager _T = TypeVar('_T') @@ -11,7 +10,4 @@ class GeneratorContextManager(ContextManager[_T], Generic[_T]): def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., GeneratorContextManager[_T]]: ... -if sys.version_info >= (3, 7): - from typing import AsyncIterator - from typing import AsyncContextManager as AsyncContextManager - def asynccontextmanager(func: Callable[..., AsyncIterator[_T]]) -> Callable[..., AsyncContextManager[_T]]: ... +def asynccontextmanager(func: Callable[..., AsyncIterator[_T]]) -> Callable[..., AsyncContextManager[_T]]: ... diff --git a/test-data/unit/lib-stub/mypy_extensions.pyi b/test-data/unit/lib-stub/mypy_extensions.pyi index d79be8719417..56fac31e7219 100644 --- a/test-data/unit/lib-stub/mypy_extensions.pyi +++ b/test-data/unit/lib-stub/mypy_extensions.pyi @@ -3,7 +3,6 @@ from typing import ( Any, Dict, Type, TypeVar, Optional, Any, Generic, Mapping, NoReturn as NoReturn, Iterator, Union, Protocol ) -import sys _T = TypeVar('_T') _U = TypeVar('_U') @@ -33,8 +32,6 @@ class _TypedDict(Mapping[str, object]): # Mypy expects that 'default' has a type variable type. def pop(self, k: NoReturn, default: _T = ...) -> object: ... def update(self: _T, __m: _T) -> None: ... - if sys.version_info < (3, 0): - def has_key(self, k: str) -> bool: ... def __delitem__(self, k: NoReturn) -> None: ... def TypedDict(typename: str, fields: Dict[str, Type[_T]], *, total: Any = ...) -> Type[dict]: ... @@ -50,68 +47,67 @@ mypyc_attr: Any class FlexibleAlias(Generic[_T, _U]): ... -if sys.version_info >= (3, 0): - class __SupportsInt(Protocol[T_co]): - def __int__(self) -> int: pass - - _Int = Union[int, i32, i64] - - class i32: - def __init__(self, x: Union[_Int, str, bytes, SupportsInt], base: int = 10) -> None: ... - def __add__(self, x: i32) -> i32: ... - def __radd__(self, x: i32) -> i32: ... - def __sub__(self, x: i32) -> i32: ... - def __rsub__(self, x: i32) -> i32: ... - def __mul__(self, x: i32) -> i32: ... - def __rmul__(self, x: i32) -> i32: ... - def __floordiv__(self, x: i32) -> i32: ... - def __rfloordiv__(self, x: i32) -> i32: ... - def __mod__(self, x: i32) -> i32: ... - def __rmod__(self, x: i32) -> i32: ... - def __and__(self, x: i32) -> i32: ... - def __rand__(self, x: i32) -> i32: ... - def __or__(self, x: i32) -> i32: ... - def __ror__(self, x: i32) -> i32: ... - def __xor__(self, x: i32) -> i32: ... - def __rxor__(self, x: i32) -> i32: ... - def __lshift__(self, x: i32) -> i32: ... - def __rlshift__(self, x: i32) -> i32: ... - def __rshift__(self, x: i32) -> i32: ... - def __rrshift__(self, x: i32) -> i32: ... - def __neg__(self) -> i32: ... - def __invert__(self) -> i32: ... - def __pos__(self) -> i32: ... - def __lt__(self, x: i32) -> bool: ... - def __le__(self, x: i32) -> bool: ... - def __ge__(self, x: i32) -> bool: ... - def __gt__(self, x: i32) -> bool: ... - - class i64: - def __init__(self, x: Union[_Int, str, bytes, SupportsInt], base: int = 10) -> None: ... - def __add__(self, x: i64) -> i64: ... - def __radd__(self, x: i64) -> i64: ... - def __sub__(self, x: i64) -> i64: ... - def __rsub__(self, x: i64) -> i64: ... - def __mul__(self, x: i64) -> i64: ... - def __rmul__(self, x: i64) -> i64: ... - def __floordiv__(self, x: i64) -> i64: ... - def __rfloordiv__(self, x: i64) -> i64: ... - def __mod__(self, x: i64) -> i64: ... - def __rmod__(self, x: i64) -> i64: ... - def __and__(self, x: i64) -> i64: ... - def __rand__(self, x: i64) -> i64: ... - def __or__(self, x: i64) -> i64: ... - def __ror__(self, x: i64) -> i64: ... - def __xor__(self, x: i64) -> i64: ... - def __rxor__(self, x: i64) -> i64: ... - def __lshift__(self, x: i64) -> i64: ... - def __rlshift__(self, x: i64) -> i64: ... - def __rshift__(self, x: i64) -> i64: ... - def __rrshift__(self, x: i64) -> i64: ... - def __neg__(self) -> i64: ... - def __invert__(self) -> i64: ... - def __pos__(self) -> i64: ... - def __lt__(self, x: i64) -> bool: ... - def __le__(self, x: i64) -> bool: ... - def __ge__(self, x: i64) -> bool: ... - def __gt__(self, x: i64) -> bool: ... +class __SupportsInt(Protocol[T_co]): + def __int__(self) -> int: pass + +_Int = Union[int, i32, i64] + +class i32: + def __init__(self, x: Union[_Int, str, bytes, SupportsInt], base: int = 10) -> None: ... + def __add__(self, x: i32) -> i32: ... + def __radd__(self, x: i32) -> i32: ... + def __sub__(self, x: i32) -> i32: ... + def __rsub__(self, x: i32) -> i32: ... + def __mul__(self, x: i32) -> i32: ... + def __rmul__(self, x: i32) -> i32: ... + def __floordiv__(self, x: i32) -> i32: ... + def __rfloordiv__(self, x: i32) -> i32: ... + def __mod__(self, x: i32) -> i32: ... + def __rmod__(self, x: i32) -> i32: ... + def __and__(self, x: i32) -> i32: ... + def __rand__(self, x: i32) -> i32: ... + def __or__(self, x: i32) -> i32: ... + def __ror__(self, x: i32) -> i32: ... + def __xor__(self, x: i32) -> i32: ... + def __rxor__(self, x: i32) -> i32: ... + def __lshift__(self, x: i32) -> i32: ... + def __rlshift__(self, x: i32) -> i32: ... + def __rshift__(self, x: i32) -> i32: ... + def __rrshift__(self, x: i32) -> i32: ... + def __neg__(self) -> i32: ... + def __invert__(self) -> i32: ... + def __pos__(self) -> i32: ... + def __lt__(self, x: i32) -> bool: ... + def __le__(self, x: i32) -> bool: ... + def __ge__(self, x: i32) -> bool: ... + def __gt__(self, x: i32) -> bool: ... + +class i64: + def __init__(self, x: Union[_Int, str, bytes, SupportsInt], base: int = 10) -> None: ... + def __add__(self, x: i64) -> i64: ... + def __radd__(self, x: i64) -> i64: ... + def __sub__(self, x: i64) -> i64: ... + def __rsub__(self, x: i64) -> i64: ... + def __mul__(self, x: i64) -> i64: ... + def __rmul__(self, x: i64) -> i64: ... + def __floordiv__(self, x: i64) -> i64: ... + def __rfloordiv__(self, x: i64) -> i64: ... + def __mod__(self, x: i64) -> i64: ... + def __rmod__(self, x: i64) -> i64: ... + def __and__(self, x: i64) -> i64: ... + def __rand__(self, x: i64) -> i64: ... + def __or__(self, x: i64) -> i64: ... + def __ror__(self, x: i64) -> i64: ... + def __xor__(self, x: i64) -> i64: ... + def __rxor__(self, x: i64) -> i64: ... + def __lshift__(self, x: i64) -> i64: ... + def __rlshift__(self, x: i64) -> i64: ... + def __rshift__(self, x: i64) -> i64: ... + def __rrshift__(self, x: i64) -> i64: ... + def __neg__(self) -> i64: ... + def __invert__(self) -> i64: ... + def __pos__(self) -> i64: ... + def __lt__(self, x: i64) -> bool: ... + def __le__(self, x: i64) -> bool: ... + def __ge__(self, x: i64) -> bool: ... + def __gt__(self, x: i64) -> bool: ...