Thanks to visit codestin.com
Credit goes to github.com

Skip to content

random: use bound methods #7408

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 24 additions & 48 deletions stdlib/random.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -122,53 +122,29 @@ class SystemRandom(Random):
def setstate(self, *args: Any, **kwds: Any) -> NoReturn: ...

# ----- random function stubs -----
if sys.version_info >= (3, 9):
def seed(a: int | float | str | bytes | bytearray | None = ..., version: int = ...) -> None: ...

else:
def seed(a: Any = ..., version: int = ...) -> None: ...

def getstate() -> object: ...
def setstate(state: object) -> None: ...
def getrandbits(__k: int) -> int: ...
def randrange(start: int, stop: 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: SupportsLenAndGetItem[_T]) -> _T: ...
def choices(
population: SupportsLenAndGetItem[_T],
weights: Sequence[float] | None = ...,
*,
cum_weights: Sequence[float] | None = ...,
k: int = ...,
) -> list[_T]: ...
def shuffle(x: MutableSequence[Any], random: Callable[[], float] | None = ...) -> None: ...

_inst: Random = ...
seed = _inst.seed
random = _inst.random
uniform = _inst.uniform
triangular = _inst.triangular
randint = _inst.randint
choice = _inst.choice
randrange = _inst.randrange
sample = _inst.sample
shuffle = _inst.shuffle
choices = _inst.choices
normalvariate = _inst.normalvariate
lognormvariate = _inst.lognormvariate
expovariate = _inst.expovariate
vonmisesvariate = _inst.vonmisesvariate
gammavariate = _inst.gammavariate
gauss = _inst.gauss
betavariate = _inst.betavariate
paretovariate = _inst.paretovariate
weibullvariate = _inst.weibullvariate
getstate = _inst.getstate
setstate = _inst.setstate
getrandbits = _inst.getrandbits
if sys.version_info >= (3, 9):
def sample(population: Sequence[_T] | AbstractSet[_T], k: int, *, counts: Iterable[_T] | None = ...) -> list[_T]: ...

else:
def sample(population: 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 | None = ...) -> float: ...
def betavariate(alpha: float, beta: float) -> float: ...
def expovariate(lambd: float) -> float: ...
def gammavariate(alpha: float, beta: float) -> float: ...

if sys.version_info >= (3, 11):
def gauss(mu: float = ..., sigma: float = ...) -> float: ...
def normalvariate(mu: float = ..., sigma: float = ...) -> float: ...

else:
def gauss(mu: float, sigma: float) -> float: ...
def normalvariate(mu: float, sigma: float) -> float: ...

def lognormvariate(mu: float, sigma: float) -> float: ...
def vonmisesvariate(mu: float, kappa: float) -> float: ...
def paretovariate(alpha: float) -> float: ...
def weibullvariate(alpha: float, beta: float) -> float: ...
randbytes = _inst.randbytes
1 change: 0 additions & 1 deletion tests/stubtest_allowlists/py36.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ mmap.ACCESS_DEFAULT
(os|posix).utime
pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args
random.Random.randrange # missing undocumented arg _int
random.randrange # missing undocumented arg _int
sched.Event.__doc__ # __slots__ is overridden
stringprep.unicodedata # re-exported from unicodedata
sre_compile.dis
Expand Down
1 change: 0 additions & 1 deletion tests/stubtest_allowlists/py37.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ json.loads
pyexpat.XMLParserType.ExternalEntityParserCreate # C signature is wrong - function gets only positional args
queue.SimpleQueue.__init__ # Default C __init__ signature is wrong
random.Random.randrange # missing undocumented arg _int
random.randrange # missing undocumented arg _int
re.Pattern.scanner # Undocumented and not useful. #6405
sched.Event.__doc__ # __slots__ is overridden
ssl.PROTOCOL_SSLv3 # Depends on ssl compilation
Expand Down
1 change: 0 additions & 1 deletion tests/stubtest_allowlists/py38.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ multiprocessing.spawn._main
pickle.Pickler.reducer_override # implemented in C pickler
queue.SimpleQueue.__init__ # Default C __init__ signature is wrong
random.Random.randrange # missing undocumented arg _int
random.randrange # missing undocumented arg _int
re.Pattern.scanner # Undocumented and not useful. #6405
sched.Event.__doc__ # __slots__ is overridden
ssl.PROTOCOL_SSLv3 # Depends on ssl compilation
Expand Down