From 2a1ef3735d4cdbdf180a344ed355217a9f36cac3 Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Sun, 5 Dec 2021 06:52:34 -0800 Subject: [PATCH] random: add VERSION, SystemRandom.getrandbits is not pos only (#6419) Co-authored-by: Akuli Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- stdlib/random.pyi | 4 +++- tests/stubtest_allowlists/py310.txt | 2 -- tests/stubtest_allowlists/py3_common.txt | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/stdlib/random.pyi b/stdlib/random.pyi index 699c56351..26b3a540f 100644 --- a/stdlib/random.pyi +++ b/stdlib/random.pyi @@ -2,11 +2,12 @@ import _random import sys from collections.abc import Callable, Iterable, MutableSequence, Sequence from fractions import Fraction -from typing import Any, NoReturn, Tuple, TypeVar +from typing import Any, ClassVar, NoReturn, Tuple, TypeVar _T = TypeVar("_T") class Random(_random.Random): + VERSION: ClassVar[int] def __init__(self, x: Any = ...) -> None: ... def seed(self, a: Any = ..., version: int = ...) -> None: ... def getstate(self) -> Tuple[Any, ...]: ... @@ -45,6 +46,7 @@ class Random(_random.Random): # SystemRandom is not implemented for all OS's; good on Windows & Linux class SystemRandom(Random): + def getrandbits(self, k: int) -> int: ... # k can be passed by keyword def getstate(self, *args: Any, **kwds: Any) -> NoReturn: ... def setstate(self, *args: Any, **kwds: Any) -> NoReturn: ... diff --git a/tests/stubtest_allowlists/py310.txt b/tests/stubtest_allowlists/py310.txt index b738960d8..f78f240e8 100644 --- a/tests/stubtest_allowlists/py310.txt +++ b/tests/stubtest_allowlists/py310.txt @@ -116,8 +116,6 @@ collections.abc.Generator.throw contextvars.ContextVar.reset contextvars.ContextVar.set io.IncrementalNewlineDecoder.setstate -random.SystemRandom.getrandbits -secrets.SystemRandom.getrandbits typing.SupportsRound.__round__ # These enums derive from (str, Enum). See comment in py3_common.txt diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 237a5f3cd..b14cd8f93 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -606,7 +606,6 @@ profile.Profile.trace_dispatch_i profile.Profile.trace_dispatch_l profile.Profile.trace_dispatch_mac profile.Profile.trace_dispatch_return -random.Random.VERSION rlcompleter.Completer.attr_matches rlcompleter.Completer.global_matches sunau.Au_read.initfp