Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions stdlib/inspect.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ from types import (
if sys.version_info >= (3, 7):
from types import ClassMethodDescriptorType, WrapperDescriptorType, MemberDescriptorType, MethodDescriptorType

from typing import Any, ClassVar, NamedTuple, Protocol, Tuple, Type, TypeVar, Union
from typing import AbstractSet, Any, ClassVar, NamedTuple, Protocol, Tuple, Type, TypeVar, Union
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering that we prefer to use imports from collections.abc, I'd suggest to use from collections.abc import Set as AbstractSet. Best of both worlds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

from typing_extensions import Literal, TypeGuard

#
Expand Down Expand Up @@ -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: ...
Expand Down
12 changes: 7 additions & 5 deletions stdlib/random.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import sys
from _typeshed import SupportsLenAndGetItem
from collections.abc import Callable, Iterable, MutableSequence, Sequence
from fractions import Fraction
from typing import Any, ClassVar, NoReturn, Tuple, TypeVar
from typing import AbstractSet, Any, ClassVar, NoReturn, Tuple, TypeVar

_T = TypeVar("_T")

Expand All @@ -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: ...
Expand Down Expand Up @@ -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: ...
Expand Down