From 6152bad0aff878f115ec5f7adc09ae3261916fce Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Wed, 24 May 2017 14:09:52 -0700 Subject: [PATCH] add random.choices for 3.6 (#1329) --- stdlib/3/random.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stdlib/3/random.pyi b/stdlib/3/random.pyi index f40d97320..e32f1bb6e 100644 --- a/stdlib/3/random.pyi +++ b/stdlib/3/random.pyi @@ -7,8 +7,9 @@ # ----- random classes ----- import _random +import sys from typing import ( - Any, TypeVar, Sequence, List, Callable, AbstractSet, Union + Any, TypeVar, Sequence, List, Callable, AbstractSet, Union, Optional ) _T = TypeVar('_T') @@ -50,6 +51,8 @@ def getrandbits(k: int) -> int: ... def randrange(start: int, stop: Union[None, int] = ..., step: int = ...) -> int: ... def randint(a: int, b: int) -> int: ... 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: ... def sample(population: Union[Sequence[_T], AbstractSet[_T]], k: int) -> List[_T]: ... def random() -> float: ...