diff --git a/stdlib/_codecs.pyi b/stdlib/_codecs.pyi index ecf874d33ddd..072808048704 100644 --- a/stdlib/_codecs.pyi +++ b/stdlib/_codecs.pyi @@ -47,11 +47,11 @@ _StrToStrEncoding: TypeAlias = Literal["rot13", "rot_13"] @overload def encode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ... @overload -def encode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ... # type: ignore[overload-overlap] +def encode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ... @overload def encode(obj: str, encoding: str = "utf-8", errors: str = "strict") -> bytes: ... @overload -def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ... # type: ignore[overload-overlap] +def decode(obj: ReadableBuffer, encoding: _BytesToBytesEncoding, errors: str = "strict") -> bytes: ... @overload def decode(obj: str, encoding: _StrToStrEncoding, errors: str = "strict") -> str: ... diff --git a/stdlib/asyncio/tasks.pyi b/stdlib/asyncio/tasks.pyi index f23ecef126d6..a955e47e51e3 100644 --- a/stdlib/asyncio/tasks.pyi +++ b/stdlib/asyncio/tasks.pyi @@ -89,7 +89,7 @@ else: ) -> Iterator[Future[_T]]: ... @overload -def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = None) -> _FT: ... # type: ignore[overload-overlap] +def ensure_future(coro_or_future: _FT, *, loop: AbstractEventLoop | None = None) -> _FT: ... @overload def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | None = None) -> Task[_T]: ... @@ -101,13 +101,13 @@ def ensure_future(coro_or_future: Awaitable[_T], *, loop: AbstractEventLoop | No # N.B. Having overlapping overloads is the only way to get acceptable type inference in all edge cases. if sys.version_info >= (3, 10): @overload - def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... # type: ignore[overload-overlap] + def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: Literal[False] = False) -> Future[tuple[_T1]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: Literal[False] = False ) -> Future[tuple[_T1, _T2]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -116,7 +116,7 @@ if sys.version_info >= (3, 10): return_exceptions: Literal[False] = False, ) -> Future[tuple[_T1, _T2, _T3]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -126,7 +126,7 @@ if sys.version_info >= (3, 10): return_exceptions: Literal[False] = False, ) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -137,7 +137,7 @@ if sys.version_info >= (3, 10): return_exceptions: Literal[False] = False, ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -149,15 +149,15 @@ if sys.version_info >= (3, 10): return_exceptions: Literal[False] = False, ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... @overload - def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... # type: ignore[overload-overlap] + def gather(*coros_or_futures: _FutureLike[_T], return_exceptions: Literal[False] = False) -> Future[list[_T]]: ... @overload - def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... # type: ignore[overload-overlap] + def gather(coro_or_future1: _FutureLike[_T1], /, *, return_exceptions: bool) -> Future[tuple[_T1 | BaseException]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, *, return_exceptions: bool ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -166,7 +166,7 @@ if sys.version_info >= (3, 10): return_exceptions: bool, ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -176,7 +176,7 @@ if sys.version_info >= (3, 10): return_exceptions: bool, ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -189,7 +189,7 @@ if sys.version_info >= (3, 10): tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException, _T5 | BaseException] ]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -214,11 +214,11 @@ if sys.version_info >= (3, 10): else: @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], /, *, loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False ) -> Future[tuple[_T1]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, @@ -227,7 +227,7 @@ else: return_exceptions: Literal[False] = False, ) -> Future[tuple[_T1, _T2]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -237,7 +237,7 @@ else: return_exceptions: Literal[False] = False, ) -> Future[tuple[_T1, _T2, _T3]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -248,7 +248,7 @@ else: return_exceptions: Literal[False] = False, ) -> Future[tuple[_T1, _T2, _T3, _T4]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -260,7 +260,7 @@ else: return_exceptions: Literal[False] = False, ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -273,15 +273,15 @@ else: return_exceptions: Literal[False] = False, ) -> Future[tuple[_T1, _T2, _T3, _T4, _T5, _T6]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( *coros_or_futures: _FutureLike[_T], loop: AbstractEventLoop | None = None, return_exceptions: Literal[False] = False ) -> Future[list[_T]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], /, *, loop: AbstractEventLoop | None = None, return_exceptions: bool ) -> Future[tuple[_T1 | BaseException]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], /, @@ -290,7 +290,7 @@ else: return_exceptions: bool, ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -300,7 +300,7 @@ else: return_exceptions: bool, ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -311,7 +311,7 @@ else: return_exceptions: bool, ) -> Future[tuple[_T1 | BaseException, _T2 | BaseException, _T3 | BaseException, _T4 | BaseException]]: ... @overload - def gather( # type: ignore[overload-overlap] + def gather( coro_or_future1: _FutureLike[_T1], coro_or_future2: _FutureLike[_T2], coro_or_future3: _FutureLike[_T3], @@ -367,7 +367,7 @@ if sys.version_info >= (3, 11): elif sys.version_info >= (3, 10): @overload - async def wait( # type: ignore[overload-overlap] + async def wait( fs: Iterable[_FT], *, timeout: float | None = None, return_when: str = "ALL_COMPLETED" ) -> tuple[set[_FT], set[_FT]]: ... @overload @@ -377,7 +377,7 @@ elif sys.version_info >= (3, 10): else: @overload - async def wait( # type: ignore[overload-overlap] + async def wait( fs: Iterable[_FT], *, loop: AbstractEventLoop | None = None, diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index bd9e759e90fb..35e1addbd553 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1685,9 +1685,9 @@ def pow(base: float, exp: complex | _SupportsSomeKindOfPow, mod: None = None) -> @overload def pow(base: complex, exp: complex | _SupportsSomeKindOfPow, mod: None = None) -> complex: ... @overload -def pow(base: _SupportsPow2[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ... # type: ignore[overload-overlap] +def pow(base: _SupportsPow2[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ... @overload -def pow(base: _SupportsPow3NoneOnly[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ... # type: ignore[overload-overlap] +def pow(base: _SupportsPow3NoneOnly[_E, _T_co], exp: _E, mod: None = None) -> _T_co: ... @overload def pow(base: _SupportsPow3[_E, _M, _T_co], exp: _E, mod: _M) -> _T_co: ... @overload @@ -1744,7 +1744,7 @@ _SupportsSumNoDefaultT = TypeVar("_SupportsSumNoDefaultT", bound=_SupportsSumWit # without creating many false-positive errors (see #7578). # Instead, we special-case the most common examples of this: bool and literal integers. @overload -def sum(iterable: Iterable[bool | _LiteralInteger], /, start: int = 0) -> int: ... # type: ignore[overload-overlap] +def sum(iterable: Iterable[bool | _LiteralInteger], /, start: int = 0) -> int: ... @overload def sum(iterable: Iterable[_SupportsSumNoDefaultT], /) -> _SupportsSumNoDefaultT | Literal[0]: ... @overload @@ -1754,7 +1754,7 @@ def sum(iterable: Iterable[_AddableT1], /, start: _AddableT2) -> _AddableT1 | _A # (A "SupportsDunderDict" protocol doesn't work) # Use a type: ignore to make complaints about overlapping overloads go away @overload -def vars(object: type, /) -> types.MappingProxyType[str, Any]: ... # type: ignore[overload-overlap] +def vars(object: type, /) -> types.MappingProxyType[str, Any]: ... @overload def vars(object: Any = ..., /) -> dict[str, Any]: ... diff --git a/stdlib/importlib/metadata/__init__.pyi b/stdlib/importlib/metadata/__init__.pyi index 37b9a3882179..b45a8be3a367 100644 --- a/stdlib/importlib/metadata/__init__.pyi +++ b/stdlib/importlib/metadata/__init__.pyi @@ -277,7 +277,7 @@ if sys.version_info >= (3, 12): elif sys.version_info >= (3, 10): @overload - def entry_points() -> SelectableGroups: ... # type: ignore[overload-overlap] + def entry_points() -> SelectableGroups: ... @overload def entry_points( *, name: str = ..., value: str = ..., group: str = ..., module: str = ..., attr: str = ..., extras: list[str] = ... diff --git a/stdlib/math.pyi b/stdlib/math.pyi index 2bb61e0669b4..b1eae68f2487 100644 --- a/stdlib/math.pyi +++ b/stdlib/math.pyi @@ -100,7 +100,7 @@ elif sys.version_info >= (3, 9): def perm(n: SupportsIndex, k: SupportsIndex | None = None, /) -> int: ... def pow(x: _SupportsFloatOrIndex, y: _SupportsFloatOrIndex, /) -> float: ... @overload -def prod(iterable: Iterable[SupportsIndex], /, *, start: SupportsIndex = 1) -> int: ... # type: ignore[overload-overlap] +def prod(iterable: Iterable[SupportsIndex], /, *, start: SupportsIndex = 1) -> int: ... @overload def prod(iterable: Iterable[_SupportsFloatOrIndex], /, *, start: _SupportsFloatOrIndex = 1) -> float: ... def radians(x: _SupportsFloatOrIndex, /) -> float: ... diff --git a/stdlib/re.pyi b/stdlib/re.pyi index b06f494c0b7d..76f98dd9f2a2 100644 --- a/stdlib/re.pyi +++ b/stdlib/re.pyi @@ -74,7 +74,7 @@ class Match(Generic[AnyStr]): @overload def expand(self: Match[str], template: str) -> str: ... @overload - def expand(self: Match[bytes], template: ReadableBuffer) -> bytes: ... # type: ignore[overload-overlap] + def expand(self: Match[bytes], template: ReadableBuffer) -> bytes: ... @overload def expand(self, template: AnyStr) -> AnyStr: ... # group() returns "AnyStr" or "AnyStr | None", depending on the pattern. @@ -124,19 +124,21 @@ class Pattern(Generic[AnyStr]): @overload def search(self: Pattern[str], string: str, pos: int = 0, endpos: int = sys.maxsize) -> Match[str] | None: ... @overload - def search(self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize) -> Match[bytes] | None: ... # type: ignore[overload-overlap] + def search(self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize) -> Match[bytes] | None: ... @overload def search(self, string: AnyStr, pos: int = 0, endpos: int = sys.maxsize) -> Match[AnyStr] | None: ... @overload def match(self: Pattern[str], string: str, pos: int = 0, endpos: int = sys.maxsize) -> Match[str] | None: ... @overload - def match(self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize) -> Match[bytes] | None: ... # type: ignore[overload-overlap] + def match(self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize) -> Match[bytes] | None: ... @overload def match(self, string: AnyStr, pos: int = 0, endpos: int = sys.maxsize) -> Match[AnyStr] | None: ... @overload def fullmatch(self: Pattern[str], string: str, pos: int = 0, endpos: int = sys.maxsize) -> Match[str] | None: ... @overload - def fullmatch(self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize) -> Match[bytes] | None: ... # type: ignore[overload-overlap] + def fullmatch( + self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize + ) -> Match[bytes] | None: ... @overload def fullmatch(self, string: AnyStr, pos: int = 0, endpos: int = sys.maxsize) -> Match[AnyStr] | None: ... @overload @@ -155,13 +157,15 @@ class Pattern(Generic[AnyStr]): @overload def finditer(self: Pattern[str], string: str, pos: int = 0, endpos: int = sys.maxsize) -> Iterator[Match[str]]: ... @overload - def finditer(self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize) -> Iterator[Match[bytes]]: ... # type: ignore[overload-overlap] + def finditer( + self: Pattern[bytes], string: ReadableBuffer, pos: int = 0, endpos: int = sys.maxsize + ) -> Iterator[Match[bytes]]: ... @overload def finditer(self, string: AnyStr, pos: int = 0, endpos: int = sys.maxsize) -> Iterator[Match[AnyStr]]: ... @overload def sub(self: Pattern[str], repl: str | Callable[[Match[str]], str], string: str, count: int = 0) -> str: ... @overload - def sub( # type: ignore[overload-overlap] + def sub( self: Pattern[bytes], repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], string: ReadableBuffer, @@ -172,7 +176,7 @@ class Pattern(Generic[AnyStr]): @overload def subn(self: Pattern[str], repl: str | Callable[[Match[str]], str], string: str, count: int = 0) -> tuple[str, int]: ... @overload - def subn( # type: ignore[overload-overlap] + def subn( self: Pattern[bytes], repl: ReadableBuffer | Callable[[Match[bytes]], ReadableBuffer], string: ReadableBuffer, diff --git a/stdlib/tempfile.pyi b/stdlib/tempfile.pyi index d31fd74d3482..62422b84eb37 100644 --- a/stdlib/tempfile.pyi +++ b/stdlib/tempfile.pyi @@ -463,7 +463,7 @@ class TemporaryDirectory(Generic[AnyStr]): # The overloads overlap, but they should still work fine. @overload -def mkstemp( # type: ignore[overload-overlap] +def mkstemp( suffix: str | None = None, prefix: str | None = None, dir: StrPath | None = None, text: bool = False ) -> tuple[int, str]: ... @overload @@ -473,7 +473,7 @@ def mkstemp( # The overloads overlap, but they should still work fine. @overload -def mkdtemp(suffix: str | None = None, prefix: str | None = None, dir: StrPath | None = None) -> str: ... # type: ignore[overload-overlap] +def mkdtemp(suffix: str | None = None, prefix: str | None = None, dir: StrPath | None = None) -> str: ... @overload def mkdtemp(suffix: bytes | None = None, prefix: bytes | None = None, dir: BytesPath | None = None) -> bytes: ... def mktemp(suffix: str = "", prefix: str = "tmp", dir: StrPath | None = None) -> str: ... diff --git a/stdlib/tkinter/ttk.pyi b/stdlib/tkinter/ttk.pyi index 86a23ce82211..24ce5ad4ab66 100644 --- a/stdlib/tkinter/ttk.pyi +++ b/stdlib/tkinter/ttk.pyi @@ -1040,7 +1040,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): @overload def heading(self, column: str | int, option: str) -> Any: ... @overload - def heading(self, column: str | int, option: None = None) -> _TreeviewHeaderDict: ... # type: ignore[overload-overlap] + def heading(self, column: str | int, option: None = None) -> _TreeviewHeaderDict: ... @overload def heading( self, @@ -1084,7 +1084,7 @@ class Treeview(Widget, tkinter.XView, tkinter.YView): @overload def item(self, item: str | int, option: str) -> Any: ... @overload - def item(self, item: str | int, option: None = None) -> _TreeviewItemDict: ... # type: ignore[overload-overlap] + def item(self, item: str | int, option: None = None) -> _TreeviewItemDict: ... @overload def item( self, diff --git a/stdlib/turtle.pyi b/stdlib/turtle.pyi index 199feee746cb..29d289303927 100644 --- a/stdlib/turtle.pyi +++ b/stdlib/turtle.pyi @@ -338,7 +338,7 @@ class TPen: def isvisible(self) -> bool: ... # Note: signatures 1 and 2 overlap unsafely when no arguments are provided @overload - def pen(self) -> _PenState: ... # type: ignore[overload-overlap] + def pen(self) -> _PenState: ... @overload def pen( self, @@ -384,7 +384,7 @@ class RawTurtle(TPen, TNavigator): def shape(self, name: str) -> None: ... # Unsafely overlaps when no arguments are provided @overload - def shapesize(self) -> tuple[float, float, float]: ... # type: ignore[overload-overlap] + def shapesize(self) -> tuple[float, float, float]: ... @overload def shapesize( self, stretch_wid: float | None = None, stretch_len: float | None = None, outline: float | None = None @@ -395,7 +395,7 @@ class RawTurtle(TPen, TNavigator): def shearfactor(self, shear: float) -> None: ... # Unsafely overlaps when no arguments are provided @overload - def shapetransform(self) -> tuple[float, float, float, float]: ... # type: ignore[overload-overlap] + def shapetransform(self) -> tuple[float, float, float, float]: ... @overload def shapetransform( self, t11: float | None = None, t12: float | None = None, t21: float | None = None, t22: float | None = None @@ -622,7 +622,7 @@ def isvisible() -> bool: ... # Note: signatures 1 and 2 overlap unsafely when no arguments are provided @overload -def pen() -> _PenState: ... # type: ignore[overload-overlap] +def pen() -> _PenState: ... @overload def pen( pen: _PenState | None = None, @@ -661,7 +661,7 @@ if sys.version_info >= (3, 12): # Unsafely overlaps when no arguments are provided @overload -def shapesize() -> tuple[float, float, float]: ... # type: ignore[overload-overlap] +def shapesize() -> tuple[float, float, float]: ... @overload def shapesize(stretch_wid: float | None = None, stretch_len: float | None = None, outline: float | None = None) -> None: ... @overload @@ -671,7 +671,7 @@ def shearfactor(shear: float) -> None: ... # Unsafely overlaps when no arguments are provided @overload -def shapetransform() -> tuple[float, float, float, float]: ... # type: ignore[overload-overlap] +def shapetransform() -> tuple[float, float, float, float]: ... @overload def shapetransform( t11: float | None = None, t12: float | None = None, t21: float | None = None, t22: float | None = None diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 1e3eacd9f1fa..7a0f1eef5b54 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -583,7 +583,7 @@ _P = ParamSpec("_P") # it's not really an Awaitable, but can be used in an await expression. Real type: Generator & Awaitable @overload -def coroutine(func: Callable[_P, Generator[Any, Any, _R]]) -> Callable[_P, Awaitable[_R]]: ... # type: ignore[overload-overlap] +def coroutine(func: Callable[_P, Generator[Any, Any, _R]]) -> Callable[_P, Awaitable[_R]]: ... @overload def coroutine(func: _Fn) -> _Fn: ... diff --git a/stdlib/unittest/mock.pyi b/stdlib/unittest/mock.pyi index 84620b7f3889..1cfd38f540a4 100644 --- a/stdlib/unittest/mock.pyi +++ b/stdlib/unittest/mock.pyi @@ -299,7 +299,7 @@ class _patcher: # Ideally we'd be able to add an overload for it so that the return type is _patch[MagicMock], # but that's impossible with the current type system. @overload - def __call__( # type: ignore[overload-overlap] + def __call__( self, target: str, new: _T, diff --git a/stubs/ExifRead/exifread/utils.pyi b/stubs/ExifRead/exifread/utils.pyi index 77034f00e133..1dace202cbd2 100644 --- a/stubs/ExifRead/exifread/utils.pyi +++ b/stubs/ExifRead/exifread/utils.pyi @@ -6,7 +6,7 @@ from typing_extensions import Self _T = TypeVar("_T") @overload -def ord_(dta: str) -> int: ... # type: ignore[overload-overlap] +def ord_(dta: str) -> int: ... @overload def ord_(dta: _T) -> _T: ... def make_string(seq: str | list[int]) -> str: ... diff --git a/stubs/Flask-Cors/flask_cors/core.pyi b/stubs/Flask-Cors/flask_cors/core.pyi index c9fdecadb93e..7ef3a38cb811 100644 --- a/stubs/Flask-Cors/flask_cors/core.pyi +++ b/stubs/Flask-Cors/flask_cors/core.pyi @@ -58,7 +58,7 @@ def get_app_kwarg_dict(appInstance: flask.Flask | None = None) -> _Options: ... def flexible_str(obj: object) -> str | None: ... def serialize_option(options_dict: _Options, key: str, upper: bool = False) -> None: ... @overload -def ensure_iterable(inst: str) -> list[str]: ... # type: ignore[overload-overlap] +def ensure_iterable(inst: str) -> list[str]: ... @overload def ensure_iterable(inst: _IterableT) -> _IterableT: ... @overload diff --git a/stubs/fpdf2/fpdf/fpdf.pyi b/stubs/fpdf2/fpdf/fpdf.pyi index f364de98183c..fc0c0445ce49 100644 --- a/stubs/fpdf2/fpdf/fpdf.pyi +++ b/stubs/fpdf2/fpdf/fpdf.pyi @@ -594,7 +594,7 @@ class FPDF(GraphicsStateMixin): repeat_headings: TableHeadingsDisplay | int = 1, ) -> _GeneratorContextManager[Table]: ... @overload - def output( # type: ignore[overload-overlap] + def output( self, name: Literal[""] | None = "", dest: Unused = "", diff --git a/stubs/openpyxl/openpyxl/descriptors/nested.pyi b/stubs/openpyxl/openpyxl/descriptors/nested.pyi index 03727c2aa932..9b9bbe6dc3d1 100644 --- a/stubs/openpyxl/openpyxl/descriptors/nested.pyi +++ b/stubs/openpyxl/openpyxl/descriptors/nested.pyi @@ -37,7 +37,7 @@ class Nested(Descriptor[_T]): def __set__(self, instance: Serialisable | Strict, value: _HasTagAndGet[_T] | _T) -> None: ... def from_tree(self, node: _HasGet[_T]) -> _T: ... @overload - def to_tree(self, tagname: Unused = None, value: None = None, namespace: Unused = None) -> None: ... # type: ignore[overload-overlap] + def to_tree(self, tagname: Unused = None, value: None = None, namespace: Unused = None) -> None: ... @overload def to_tree(self, tagname: str, value: object, namespace: str | None = None) -> Element: ... @@ -137,7 +137,7 @@ class NestedText(NestedValue[_T, _N]): # So we implement explicitly the types used internally # str @overload - def __set__( # type: ignore[overload-overlap] + def __set__( self: NestedText[str, _N], instance: Serialisable | Strict, value: object # Not[None] when _N = False ) -> None: ... # int @@ -155,7 +155,7 @@ class NestedText(NestedValue[_T, _N]): def __set__(self: NestedText[_T, Literal[True]], instance: Serialisable | Strict, value: _T | int | Any | None) -> None: ... def from_tree(self, node: _HasText) -> str: ... # type: ignore[override] @overload - def to_tree(self, tagname: Unused = None, value: None = None, namespace: Unused = None) -> None: ... # type: ignore[overload-overlap] + def to_tree(self, tagname: Unused = None, value: None = None, namespace: Unused = None) -> None: ... @overload def to_tree(self, tagname: str, value: object, namespace: str | None = None) -> Element: ... @@ -271,8 +271,6 @@ class EmptyTag(Nested[bool], Bool[_N]): # type: ignore[misc] def __set__(self, instance: Serialisable | Strict, value: _HasTagAndGet[_ConvertibleToBool] | _ConvertibleToBool) -> None: ... def from_tree(self, node: Unused) -> Literal[True]: ... @overload - def to_tree( # type: ignore[overload-overlap] - self, tagname: Unused = None, value: None = None, namespace: Unused = None - ) -> None: ... + def to_tree(self, tagname: Unused = None, value: None = None, namespace: Unused = None) -> None: ... @overload def to_tree(self, tagname: str, value: object, namespace: str | None = None) -> Element: ... diff --git a/stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi b/stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi index 910a86b6c885..cbdac51f363c 100644 --- a/stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi +++ b/stubs/openpyxl/openpyxl/xml/_functions_overloads.pyi @@ -77,7 +77,7 @@ def fromstring(text: str | ReadableBuffer, parser: XMLParser | None = None) -> E # from lxml.etree import fromstring # But made partial, removing parser arg @overload -def fromstring(text: str | bytes, *, base_url: str | bytes = ...) -> _lxml_Element: ... # type: ignore[overload-overlap] +def fromstring(text: str | bytes, *, base_url: str | bytes = ...) -> _lxml_Element: ... # from defusedxml.ElementTree import fromstring @overload diff --git a/stubs/psycopg2/psycopg2/extensions.pyi b/stubs/psycopg2/psycopg2/extensions.pyi index 77e12076674f..aa35a8ba2ba1 100644 --- a/stubs/psycopg2/psycopg2/extensions.pyi +++ b/stubs/psycopg2/psycopg2/extensions.pyi @@ -113,7 +113,7 @@ class NoneAdapter: def getquoted(self, _null: bytes = b"NULL") -> bytes: ... @overload -def make_dsn(dsn: bytes) -> bytes: ... # type: ignore[overload-overlap] +def make_dsn(dsn: bytes) -> bytes: ... @overload def make_dsn(dsn: None = None) -> str: ... @overload diff --git a/stubs/pycocotools/pycocotools/mask.pyi b/stubs/pycocotools/pycocotools/mask.pyi index 1571d7bd987d..37825152c91f 100644 --- a/stubs/pycocotools/pycocotools/mask.pyi +++ b/stubs/pycocotools/pycocotools/mask.pyi @@ -22,7 +22,7 @@ def merge(rleObjs: list[_EncodedRLE], intersect: int = ...) -> _EncodedRLE: ... # ignore an "overlapping overloads" error due to _NDArrayInt32 being an alias for `Incomplete` for now @overload -def frPyObjects(pyobj: _NDArrayUInt32 | list[list[int]] | list[_EncodedRLE], h: int, w: int) -> list[_EncodedRLE]: ... # type: ignore[overload-overlap] +def frPyObjects(pyobj: _NDArrayUInt32 | list[list[int]] | list[_EncodedRLE], h: int, w: int) -> list[_EncodedRLE]: ... @overload def frPyObjects(pyobj: list[int] | _EncodedRLE, h: int, w: int) -> _EncodedRLE: ... def encode(bimask: _NDArrayUInt8) -> _EncodedRLE: ... diff --git a/stubs/pyflakes/pyflakes/checker.pyi b/stubs/pyflakes/pyflakes/checker.pyi index 4a18d8d70327..10088ecca4b0 100644 --- a/stubs/pyflakes/pyflakes/checker.pyi +++ b/stubs/pyflakes/pyflakes/checker.pyi @@ -39,11 +39,11 @@ _OmitType: TypeAlias = str | tuple[str, ...] | None def iter_child_nodes(node: ast.AST, omit: _OmitType = None, _fields_order: _FieldsOrder = ...) -> Iterator[ast.AST]: ... @overload -def convert_to_value(item: ast.Str) -> str: ... # type: ignore[overload-overlap] +def convert_to_value(item: ast.Str) -> str: ... @overload -def convert_to_value(item: ast.Bytes) -> bytes: ... # type: ignore[overload-overlap] +def convert_to_value(item: ast.Bytes) -> bytes: ... @overload -def convert_to_value(item: ast.Tuple) -> tuple[Any, ...]: ... # type: ignore[overload-overlap] +def convert_to_value(item: ast.Tuple) -> tuple[Any, ...]: ... @overload def convert_to_value(item: ast.Name | ast.NameConstant) -> Any: ... @overload diff --git a/stubs/seaborn/seaborn/palettes.pyi b/stubs/seaborn/seaborn/palettes.pyi index 64ea321d28e5..d7c4b5dad69b 100644 --- a/stubs/seaborn/seaborn/palettes.pyi +++ b/stubs/seaborn/seaborn/palettes.pyi @@ -38,7 +38,7 @@ _SeabornPaletteName: TypeAlias = Literal[ ] @overload -def color_palette( # type: ignore[overload-overlap] +def color_palette( palette: _SeabornPaletteName | None = None, n_colors: int | None = None, desat: float | None = None, *, as_cmap: Literal[True] ) -> list[str]: ... # this might be a bug in seaborn because we expect the return type to be a Colormap instance @overload diff --git a/stubs/seaborn/seaborn/utils.pyi b/stubs/seaborn/seaborn/utils.pyi index a54afc15ccd1..6d3f351f5a59 100644 --- a/stubs/seaborn/seaborn/utils.pyi +++ b/stubs/seaborn/seaborn/utils.pyi @@ -104,7 +104,7 @@ def axis_ticklabels_overlap(labels: Iterable[Text]) -> bool: ... def axes_ticklabels_overlap(ax: Axes) -> tuple[bool, bool]: ... def locator_to_legend_entries(locator: Locator, limits: Iterable[float], dtype) -> tuple[list[Incomplete], list[str]]: ... @overload -def relative_luminance(color: ColorType) -> float: ... # type: ignore[overload-overlap] +def relative_luminance(color: ColorType) -> float: ... @overload def relative_luminance(color: Sequence[ColorType]) -> NDArray[np.float64]: ... @overload diff --git a/stubs/setuptools/pkg_resources/__init__.pyi b/stubs/setuptools/pkg_resources/__init__.pyi index 2187fde20a5c..fe0ca42441a3 100644 --- a/stubs/setuptools/pkg_resources/__init__.pyi +++ b/stubs/setuptools/pkg_resources/__init__.pyi @@ -124,7 +124,7 @@ class WorkingSet: def __iter__(self) -> Iterator[Distribution]: ... def add(self, dist: Distribution, entry: str | None = None, insert: bool = True, replace: bool = False) -> None: ... @overload - def resolve( # type: ignore[overload-overlap] + def resolve( self, requirements: Iterable[Requirement], env: Environment | None, @@ -133,7 +133,7 @@ class WorkingSet: extras: tuple[str, ...] | None = None, ) -> list[_DistributionT]: ... @overload - def resolve( # type: ignore[overload-overlap] + def resolve( self, requirements: Iterable[Requirement], env: Environment | None = None, @@ -143,7 +143,7 @@ class WorkingSet: extras: tuple[str, ...] | None = None, ) -> list[_DistributionT]: ... @overload - def resolve( # type: ignore[overload-overlap] + def resolve( self, requirements: Iterable[Requirement], env: Environment | None = None, @@ -152,7 +152,7 @@ class WorkingSet: extras: tuple[str, ...] | None = None, ) -> list[Distribution]: ... @overload - def find_plugins( # type: ignore[overload-overlap] + def find_plugins( self, plugin_env: Environment, full_env: Environment | None, @@ -160,7 +160,7 @@ class WorkingSet: fallback: bool = True, ) -> tuple[list[_DistributionT], dict[Distribution, Exception]]: ... @overload - def find_plugins( # type: ignore[overload-overlap] + def find_plugins( self, plugin_env: Environment, full_env: Environment | None = None, @@ -205,7 +205,7 @@ class Environment: replace_conflicting: bool = False, ) -> Distribution | None: ... @overload - def obtain(self, requirement: Requirement, installer: _InstallerTypeT[_DistributionT]) -> _DistributionT: ... # type: ignore[overload-overlap] + def obtain(self, requirement: Requirement, installer: _InstallerTypeT[_DistributionT]) -> _DistributionT: ... @overload def obtain(self, requirement: Requirement, installer: Callable[[Requirement], None] | None = None) -> None: ... @overload diff --git a/stubs/shapely/shapely/io.pyi b/stubs/shapely/shapely/io.pyi index 27b667e5347e..ab904a42881d 100644 --- a/stubs/shapely/shapely/io.pyi +++ b/stubs/shapely/shapely/io.pyi @@ -117,7 +117,7 @@ def to_geojson(geometry: OptGeoArrayLikeSeq, indent: int | None = None, **kwargs @overload def from_wkt(geometry: None, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> None: ... @overload -def from_wkt(geometry: str, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> BaseGeometry: ... # type: ignore[overload-overlap] +def from_wkt(geometry: str, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> BaseGeometry: ... @overload def from_wkt( geometry: ArrayLikeSeq[str | None], on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs @@ -125,7 +125,7 @@ def from_wkt( @overload def from_wkb(geometry: None, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> None: ... @overload -def from_wkb(geometry: str | bytes, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> BaseGeometry: ... # type: ignore[overload-overlap] +def from_wkb(geometry: str | bytes, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> BaseGeometry: ... @overload def from_wkb( geometry: ArrayLikeSeq[str | bytes | None], on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs @@ -133,7 +133,7 @@ def from_wkb( @overload def from_geojson(geometry: None, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> None: ... @overload -def from_geojson(geometry: str | bytes, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> BaseGeometry: ... # type: ignore[overload-overlap] +def from_geojson(geometry: str | bytes, on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs) -> BaseGeometry: ... @overload def from_geojson( geometry: ArrayLikeSeq[str | bytes | None], on_invalid: Literal["raise", "warn", "ignore"] = "raise", **kwargs diff --git a/stubs/shapely/shapely/ops.pyi b/stubs/shapely/shapely/ops.pyi index a03a5f43298c..82c941507d6d 100644 --- a/stubs/shapely/shapely/ops.pyi +++ b/stubs/shapely/shapely/ops.pyi @@ -31,9 +31,9 @@ __all__ = [ class CollectionOperator: @overload - def shapeup(self, ob: GeoT) -> GeoT: ... # type: ignore[overload-overlap] + def shapeup(self, ob: GeoT) -> GeoT: ... @overload - def shapeup(self, ob: dict[str, Any] | SupportsGeoInterface) -> BaseGeometry: ... # type: ignore[overload-overlap] + def shapeup(self, ob: dict[str, Any] | SupportsGeoInterface) -> BaseGeometry: ... @overload def shapeup(self, ob: _ConvertibleToLineString) -> LineString: ... def polygonize( diff --git a/stubs/shapely/shapely/predicates.pyi b/stubs/shapely/shapely/predicates.pyi index ddf792261fa3..543437022afa 100644 --- a/stubs/shapely/shapely/predicates.pyi +++ b/stubs/shapely/shapely/predicates.pyi @@ -59,13 +59,13 @@ def is_empty(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: ... @overload def is_geometry(geometry: Geometry, **kwargs) -> Literal[True]: ... @overload -def is_geometry(geometry: ArrayLikeSeq[Any], **kwargs) -> NDArray[np.bool_]: ... # type: ignore[overload-overlap] +def is_geometry(geometry: ArrayLikeSeq[Any], **kwargs) -> NDArray[np.bool_]: ... @overload def is_geometry(geometry: object, **kwargs) -> TypeGuard[BaseGeometry]: ... @overload def is_missing(geometry: Geometry, **kwargs) -> Literal[True]: ... @overload -def is_missing(geometry: ArrayLikeSeq[Any], **kwargs) -> NDArray[np.bool_]: ... # type: ignore[overload-overlap] +def is_missing(geometry: ArrayLikeSeq[Any], **kwargs) -> NDArray[np.bool_]: ... @overload def is_missing(geometry: object, **kwargs) -> TypeGuard[BaseGeometry]: ... @overload @@ -75,7 +75,7 @@ def is_prepared(geometry: OptGeoArrayLikeSeq, **kwargs) -> NDArray[np.bool_]: .. @overload def is_valid_input(geometry: Geometry | None, **kwargs) -> Literal[True]: ... @overload -def is_valid_input(geometry: ArrayLikeSeq[Any], **kwargs) -> NDArray[np.bool_]: ... # type: ignore[overload-overlap] +def is_valid_input(geometry: ArrayLikeSeq[Any], **kwargs) -> NDArray[np.bool_]: ... @overload def is_valid_input(geometry: object, **kwargs) -> TypeGuard[BaseGeometry | None]: ... @overload diff --git a/stubs/uWSGI/uwsgi.pyi b/stubs/uWSGI/uwsgi.pyi index d42c32b30074..2bbde54161f6 100644 --- a/stubs/uWSGI/uwsgi.pyi +++ b/stubs/uWSGI/uwsgi.pyi @@ -87,7 +87,7 @@ def cache_update( def queue_get(index: int, /) -> bytes | None: ... def queue_set(index: int, message: str | bytes | ReadOnlyBuffer, /) -> _TrueOrNone: ... @overload -def queue_last(num: Literal[0] = 0, /) -> bytes | None: ... # type: ignore[overload-overlap] +def queue_last(num: Literal[0] = 0, /) -> bytes | None: ... @overload def queue_last(num: int, /) -> list[bytes | None]: ... def queue_push(message: str | bytes | ReadOnlyBuffer, /) -> _TrueOrNone: ... diff --git a/tests/mypy_test.py b/tests/mypy_test.py index 35a7fdab1153..657e013977a0 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -237,10 +237,9 @@ def run_mypy( # See https://github.com/python/typeshed/pull/9491#issuecomment-1381574946 # for discussion and reasoning to keep "--allow-subclassing-any" "--allow-subclassing-any", - "--enable-error-code", - "ignore-without-code", - "--enable-error-code", - "redundant-self", + "--enable-error-code=ignore-without-code", + "--enable-error-code=redundant-self", + "--disable-error-code=overload-overlap", "--config-file", temp.name, ] diff --git a/tests/regr_test.py b/tests/regr_test.py index c8fc9e91202c..e60390911c1d 100755 --- a/tests/regr_test.py +++ b/tests/regr_test.py @@ -184,6 +184,8 @@ def run_testcases( "--no-incremental", # Not useful for the test cases "--disable-error-code=empty-body", + "--disable-error-code=unreachable", + "--disable-error-code=overload-overlap", ] if package.is_stdlib: