diff --git a/requirements-tests.txt b/requirements-tests.txt index beb6270218a8..79b885f290db 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1,6 +1,6 @@ # Type checkers that we test our stubs against. These should always # be pinned to a specific version to make failure reproducible. -mypy==2.3.1 +mypy==2.4.0 pyrefly==1.3.2 pyright==1.1.414 ty==0.0.84 diff --git a/stdlib/@tests/stubtest_allowlists/common.txt b/stdlib/@tests/stubtest_allowlists/common.txt index 3e60c5bfd371..605e4809f793 100644 --- a/stdlib/@tests/stubtest_allowlists/common.txt +++ b/stdlib/@tests/stubtest_allowlists/common.txt @@ -43,6 +43,15 @@ builtins.super.__self__ builtins.super.__self_class__ builtins.super.__thisclass__ +# The following reverse operators are present in the C implementation +# (probably incidental), but missing from the Python implementation. +datetime.date.__rsub__ +datetime.datetime.__rsub__ +datetime.timedelta.__rdivmod__ +datetime.timedelta.__rfloordiv__ +datetime.timedelta.__rmod__ +datetime.timedelta.__rtruediv__ + # Undocumented implementation details email.contentmanager.get_and_fixup_unknown_message_content email.contentmanager.get_message_content diff --git a/stdlib/@tests/stubtest_allowlists/py315.txt b/stdlib/@tests/stubtest_allowlists/py315.txt index 68edc6e4f535..f684f7e9d2c6 100644 --- a/stdlib/@tests/stubtest_allowlists/py315.txt +++ b/stdlib/@tests/stubtest_allowlists/py315.txt @@ -4,7 +4,6 @@ dataclasses.MISSING dataclasses._MISSING_TYPE -dataclasses.field # ============================================================= # Allowlist entries that cannot or should not be fixed; >= 3.15 @@ -12,8 +11,6 @@ dataclasses.field # runtime default is a list object used as a sentinel base64.b64decode -urllib.parse.urlunparse -urllib.parse.urlunsplit # Internal implementation details of the sampling profiler. profiling.sampling.binary_collector diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 0cd6bd32b256..303be4e2e931 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -66,7 +66,7 @@ from typing import ( # noqa: Y022 # ruff: ignore[deprecated-import] # we can't import `Literal` from typing or mypy crashes: see #11247 # ruff: ignore[deprecated-import] -from typing_extensions import Literal, LiteralString, Self, TypeIs, TypeVarTuple, deprecated, disjoint_base # noqa: Y023 +from typing_extensions import Buffer, Literal, LiteralString, Self, TypeIs, TypeVarTuple, deprecated, disjoint_base # noqa: Y023 if sys.version_info >= (3, 14): from _typeshed import AnnotateFunc @@ -711,7 +711,9 @@ class str(Sequence[str]): @overload def __mod__(self: LiteralString, value: LiteralString | tuple[LiteralString, ...], /) -> LiteralString: ... @overload - def __mod__(self, value: Any, /) -> str: ... + def __mod__(self, value: object, /) -> str: ... + + def __rmod__(self, value: str, /) -> str: ... @overload def __mul__(self: LiteralString, value: SupportsIndex, /) -> LiteralString: ... @@ -826,7 +828,8 @@ class bytes(Sequence[int]): def __add__(self, value: ReadableBuffer, /) -> bytes: ... def __mul__(self, value: SupportsIndex, /) -> bytes: ... def __rmul__(self, value: SupportsIndex, /) -> bytes: ... - def __mod__(self, value: Any, /) -> bytes: ... + def __mod__(self, value: Buffer | SupportsBytes | tuple[Buffer | SupportsBytes, ...], /) -> bytes: ... + def __rmod__(self, value: bytes, /) -> bytes: ... # Incompatible with Sequence.__contains__ def __contains__(self, key: SupportsIndex | ReadableBuffer, /) -> bool: ... # type: ignore[override] def __eq__(self, value: object, /) -> bool: ... @@ -957,7 +960,8 @@ class bytearray(MutableSequence[int]): def __mul__(self, value: SupportsIndex, /) -> bytearray: ... def __rmul__(self, value: SupportsIndex, /) -> bytearray: ... def __imul__(self, value: SupportsIndex, /) -> Self: ... - def __mod__(self, value: Any, /) -> bytes: ... + def __mod__(self, value: Buffer | SupportsBytes | tuple[Buffer | SupportsBytes, ...], /) -> bytearray: ... + def __rmod__(self, value: bytearray, /) -> bytearray: ... # Incompatible with Sequence.__contains__ def __contains__(self, key: SupportsIndex | ReadableBuffer, /) -> bool: ... # type: ignore[override] def __eq__(self, value: object, /) -> bool: ... @@ -1457,12 +1461,36 @@ class set(MutableSet[_T]): def __iter__(self) -> Iterator[_T]: ... def __and__(self, value: AbstractSet[object], /) -> set[_T]: ... def __iand__(self, value: AbstractSet[object], /) -> Self: ... + + @overload + def __rand__(self, value: set[_S], /) -> set[_S]: ... + @overload + def __rand__(self, value: frozenset[_S], /) -> frozenset[_S]: ... + def __or__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... def __ior__(self, value: AbstractSet[_T], /) -> Self: ... # type: ignore[override,misc] + + @overload + def __ror__(self, value: set[_S], /) -> set[_T | _S]: ... + @overload + def __ror__(self, value: frozenset[_S], /) -> frozenset[_T | _S]: ... + def __sub__(self, value: AbstractSet[object], /) -> set[_T]: ... def __isub__(self, value: AbstractSet[object], /) -> Self: ... + + @overload + def __rsub__(self, value: set[_S], /) -> set[_S]: ... + @overload + def __rsub__(self, value: frozenset[_S], /) -> frozenset[_S]: ... + def __xor__(self, value: AbstractSet[_S], /) -> set[_T | _S]: ... def __ixor__(self, value: AbstractSet[_T], /) -> Self: ... # type: ignore[override,misc] + + @overload + def __rxor__(self, value: set[_S], /) -> set[_T | _S]: ... + @overload + def __rxor__(self, value: frozenset[_S], /) -> frozenset[_T | _S]: ... + def __le__(self, value: AbstractSet[object], /) -> bool: ... def __lt__(self, value: AbstractSet[object], /) -> bool: ... def __ge__(self, value: AbstractSet[object], /) -> bool: ... @@ -1490,9 +1518,33 @@ class frozenset(AbstractSet[_T_co]): def __contains__(self, o: object, /) -> bool: ... def __iter__(self) -> Iterator[_T_co]: ... def __and__(self, value: AbstractSet[object], /) -> frozenset[_T_co]: ... + + @overload + def __rand__(self, value: set[_S], /) -> set[_S]: ... + @overload + def __rand__(self, value: frozenset[_S], /) -> frozenset[_S]: ... + def __or__(self, value: AbstractSet[_S], /) -> frozenset[_T_co | _S]: ... + + @overload + def __ror__(self, value: set[_S], /) -> set[_T_co | _S]: ... + @overload + def __ror__(self, value: frozenset[_S], /) -> frozenset[_T_co | _S]: ... + def __sub__(self, value: AbstractSet[object], /) -> frozenset[_T_co]: ... + + @overload + def __rsub__(self, value: set[_S], /) -> set[_S]: ... + @overload + def __rsub__(self, value: frozenset[_S], /) -> frozenset[_S]: ... + def __xor__(self, value: AbstractSet[_S], /) -> frozenset[_T_co | _S]: ... + + @overload + def __rxor__(self, value: set[_S], /) -> set[_T_co | _S]: ... + @overload + def __rxor__(self, value: frozenset[_S], /) -> frozenset[_T_co | _S]: ... + def __le__(self, value: AbstractSet[object], /) -> bool: ... def __lt__(self, value: AbstractSet[object], /) -> bool: ... def __ge__(self, value: AbstractSet[object], /) -> bool: ... diff --git a/stdlib/types.pyi b/stdlib/types.pyi index 457cf609da8c..39aaa7e9685f 100644 --- a/stdlib/types.pyi +++ b/stdlib/types.pyi @@ -603,6 +603,10 @@ if sys.version_info >= (3, 15): def __len__(self) -> int: ... def __contains__(self, key: object, /) -> bool: ... def __reversed__(self) -> Iterator[str]: ... + def __or__(self, other: dict[str, Any] | FrameLocalsProxyType, /) -> dict[str, Any]: ... + # Will raise a NameError if invoked via |= + def __ior__(self, other: dict[str, Any] | FrameLocalsProxyType, /) -> dict[str, Any]: ... # noqa: Y034 + def __ror__(self, other: dict[str, Any] | FrameLocalsProxyType, /) -> dict[str, Any]: ... def copy(self) -> dict[str, Any]: ... def pop(self, key: str, default: Any = ..., /) -> Any: ... def setdefault(self, key: str, default: Any = ..., /) -> Any: ... diff --git a/stubs/tensorflow/tensorflow/io/__init__.pyi b/stubs/tensorflow/tensorflow/io/__init__.pyi index 593131b765b9..e0a7716a84dd 100644 --- a/stubs/tensorflow/tensorflow/io/__init__.pyi +++ b/stubs/tensorflow/tensorflow/io/__init__.pyi @@ -92,8 +92,8 @@ class RaggedFeature(NamedTuple): dtype: DTypeLike value_key: str | None = None - partitions: tuple[ # type: ignore[name-defined] - RowSplits | RowLengths | RowStarts | RowLimits | ValueRowIds | UniformRowLength, ... + partitions: tuple[ + RowSplits | RowLengths | RowStarts | RowLimits | ValueRowIds | UniformRowLength, ... # type: ignore[name-defined] ] = () row_splits_dtype: DTypeLike = ... validate: bool = False