fix up some C signatures (#14624)

a few issues exposed after https://github.com/python/mypy/pull/18259 was merged
This commit is contained in:
Stephen Morton
2025-08-22 06:58:55 -07:00
committed by GitHub
parent b7f7335f82
commit cc14cc6c2a
6 changed files with 122 additions and 45 deletions
+5
View File
@@ -4,6 +4,7 @@ from _typeshed import SupportsLenAndGetItem
from collections.abc import Callable, Iterable, MutableSequence, Sequence, Set as AbstractSet
from fractions import Fraction
from typing import Any, ClassVar, NoReturn, TypeVar
from typing_extensions import Self
__all__ = [
"Random",
@@ -44,6 +45,10 @@ class Random(_random.Random):
# Using other `seed` types is deprecated since 3.9 and removed in 3.11
# Ignore Y041, since random.seed doesn't treat int like a float subtype. Having an explicit
# int better documents conventional usage of random.seed.
if sys.version_info < (3, 10):
# this is a workaround for pyright correctly flagging an inconsistent inherited constructor, see #14624
def __new__(cls, x: int | float | str | bytes | bytearray | None = None) -> Self: ... # noqa: Y041
def seed(self, a: int | float | str | bytes | bytearray | None = None, version: int = 2) -> None: ... # type: ignore[override] # noqa: Y041
def getstate(self) -> tuple[Any, ...]: ...
def setstate(self, state: tuple[Any, ...]) -> None: ...