random: various fixes (#4128)

* random.sample: make counts keyword-only

* random: mark positional-only args

* random.triangular: fix type of mode

* random: add randbytes

Co-authored-by: hauntsaninja <>
This commit is contained in:
Shantanu
2020-05-27 22:05:55 -07:00
committed by GitHub
parent eca19f00fb
commit 1c0403cf83
3 changed files with 12 additions and 12 deletions

View File

@@ -17,20 +17,22 @@ class Random(_random.Random):
def seed(self, a: Any = ..., version: int = ...) -> None: ...
def getstate(self) -> Tuple[Any, ...]: ...
def setstate(self, state: Tuple[Any, ...]) -> None: ...
def getrandbits(self, k: int) -> int: ...
def getrandbits(self, __k: int) -> int: ...
def randrange(self, start: int, stop: Union[int, None] = ..., step: int = ...) -> int: ...
def randint(self, a: int, b: int) -> int: ...
if sys.version_info >= (3, 9):
def randbytes(self, n: int) -> bytes: ...
def choice(self, seq: Sequence[_T]) -> _T: ...
if sys.version_info >= (3, 6):
def choices(self, population: Sequence[_T], weights: Optional[Sequence[float]] = ..., *, cum_weights: Optional[Sequence[float]] = ..., k: int = ...) -> List[_T]: ...
def shuffle(self, x: List[Any], random: Union[Callable[[], float], None] = ...) -> None: ...
if sys.version_info >= (3, 9):
def sample(self, population: Union[Sequence[_T], AbstractSet[_T]], k: int, counts: Optional[Iterable[_T]] = ...) -> List[_T]: ...
def sample(self, population: Union[Sequence[_T], AbstractSet[_T]], k: int, *, counts: Optional[Iterable[_T]] = ...) -> List[_T]: ...
else:
def sample(self, population: Union[Sequence[_T], AbstractSet[_T]], k: int) -> List[_T]: ...
def random(self) -> float: ...
def uniform(self, a: float, b: float) -> float: ...
def triangular(self, low: float = ..., high: float = ..., mode: float = ...) -> float: ...
def triangular(self, low: float = ..., high: float = ..., mode: Optional[float] = ...) -> float: ...
def betavariate(self, alpha: float, beta: float) -> float: ...
def expovariate(self, lambd: float) -> float: ...
def gammavariate(self, alpha: float, beta: float) -> float: ...
@@ -49,21 +51,23 @@ class SystemRandom(Random):
def seed(a: Any = ..., version: int = ...) -> None: ...
def getstate() -> object: ...
def setstate(state: object) -> None: ...
def getrandbits(k: int) -> int: ...
def getrandbits(__k: int) -> int: ...
def randrange(start: int, stop: Union[None, int] = ..., step: int = ...) -> int: ...
def randint(a: int, b: int) -> int: ...
if sys.version_info >= (3, 9):
def randbytes(n: int) -> bytes: ...
def choice(seq: Sequence[_T]) -> _T: ...
if sys.version_info >= (3, 6):
def choices(population: Sequence[_T], weights: Optional[Sequence[float]] = ..., *, cum_weights: Optional[Sequence[float]] = ..., k: int = ...) -> List[_T]: ...
def shuffle(x: List[Any], random: Union[Callable[[], float], None] = ...) -> None: ...
if sys.version_info >= (3, 9):
def sample(population: Union[Sequence[_T], AbstractSet[_T]], k: int, counts: Optional[Iterable[_T]] = ...) -> List[_T]: ...
def sample(population: Union[Sequence[_T], AbstractSet[_T]], k: int, *, counts: Optional[Iterable[_T]] = ...) -> List[_T]: ...
else:
def sample(population: Union[Sequence[_T], AbstractSet[_T]], k: int) -> List[_T]: ...
def random() -> float: ...
def uniform(a: float, b: float) -> float: ...
def triangular(low: float = ..., high: float = ...,
mode: float = ...) -> float: ...
mode: Optional[float] = ...) -> float: ...
def betavariate(alpha: float, beta: float) -> float: ...
def expovariate(lambd: float) -> float: ...
def gammavariate(alpha: float, beta: float) -> float: ...

View File

@@ -166,11 +166,9 @@ profile.Profile.runcall
pwd.getpwnam
pwd.getpwuid
queue.SimpleQueue.__init__
random.Random.getrandbits
random.Random.sample
random.getrandbits
random.sample
random.SystemRandom.getrandbits
secrets.SystemRandom.getstate
secrets.SystemRandom.getrandbits
secrets.compare_digest
signal.sigtimedwait
signal.sigwaitinfo

View File

@@ -381,10 +381,8 @@ pydoc.TextDoc.docother
pydoc.TextDoc.docproperty
pydoc.TextDoc.docroutine
random.Random.randrange
random.Random.triangular
random.SystemRandom.getstate
random.randrange
random.triangular
re.error.__init__
runpy.run_path
sched.Event.__doc__