Use AbstractSet instead of set in random and inspect (#6574)

This commit is contained in:
Jukka Lehtosalo
2021-12-13 16:26:28 +00:00
committed by GitHub
parent cc054efa79
commit 78806f5402
2 changed files with 9 additions and 7 deletions

View File

@@ -3,7 +3,7 @@ import sys
import types
from _typeshed import Self
from collections import OrderedDict
from collections.abc import Awaitable, Callable, Generator, Mapping, Sequence
from collections.abc import Awaitable, Callable, Generator, Mapping, Sequence, Set as AbstractSet
from types import (
AsyncGeneratorType,
BuiltinFunctionType,
@@ -317,7 +317,7 @@ class ClosureVars(NamedTuple):
nonlocals: Mapping[str, Any]
globals: Mapping[str, Any]
builtins: Mapping[str, Any]
unbound: set[str]
unbound: AbstractSet[str]
def getclosurevars(func: Callable[..., Any]) -> ClosureVars: ...
def unwrap(func: Callable[..., Any], *, stop: Callable[[Any], Any] | None = ...) -> Any: ...

View File

@@ -1,7 +1,7 @@
import _random
import sys
from _typeshed import SupportsLenAndGetItem
from collections.abc import Callable, Iterable, MutableSequence, Sequence
from collections.abc import Callable, Iterable, MutableSequence, Sequence, Set as AbstractSet
from fractions import Fraction
from typing import Any, ClassVar, NoReturn, Tuple, TypeVar
@@ -29,9 +29,11 @@ class Random(_random.Random):
) -> list[_T]: ...
def shuffle(self, x: MutableSequence[Any], random: Callable[[], float] | None = ...) -> None: ...
if sys.version_info >= (3, 9):
def sample(self, population: Sequence[_T] | set[_T], k: int, *, counts: Iterable[_T] | None = ...) -> list[_T]: ...
def sample(
self, population: Sequence[_T] | AbstractSet[_T], k: int, *, counts: Iterable[_T] | None = ...
) -> list[_T]: ...
else:
def sample(self, population: Sequence[_T] | set[_T], k: int) -> list[_T]: ...
def sample(self, population: 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 | None = ...) -> float: ...
@@ -73,10 +75,10 @@ def choices(
def shuffle(x: MutableSequence[Any], random: Callable[[], float] | None = ...) -> None: ...
if sys.version_info >= (3, 9):
def sample(population: Sequence[_T] | set[_T], k: int, *, counts: Iterable[_T] | None = ...) -> list[_T]: ...
def sample(population: Sequence[_T] | AbstractSet[_T], k: int, *, counts: Iterable[_T] | None = ...) -> list[_T]: ...
else:
def sample(population: Sequence[_T] | set[_T], k: int) -> list[_T]: ...
def sample(population: Sequence[_T] | AbstractSet[_T], k: int) -> list[_T]: ...
def random() -> float: ...
def uniform(a: float, b: float) -> float: ...