Skip to content
Merged
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
14 changes: 10 additions & 4 deletions stdlib/statistics.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import sys
from _typeshed import SupportsRichComparisonT
from collections.abc import Callable, Hashable, Iterable, Sequence
from collections.abc import Callable, Hashable, Iterable, Sequence, Sized
from decimal import Decimal
from fractions import Fraction
from typing import Literal, NamedTuple, SupportsFloat, SupportsIndex, TypeVar
from typing import Literal, NamedTuple, Protocol, SupportsFloat, SupportsIndex, TypeVar
from typing_extensions import Self, TypeAlias

__all__ = [
Expand Down Expand Up @@ -41,6 +41,10 @@ _HashableT = TypeVar("_HashableT", bound=Hashable)
# Used in NormalDist.samples and kde_random
_Seed: TypeAlias = int | float | str | bytes | bytearray # noqa: Y041

# Used in linear_regression
_T_co = TypeVar("_T_co", covariant=True)

class _SizedIterable(Iterable[_T_co], Sized, Protocol[_T_co]): ...
class StatisticsError(ValueError): ...

if sys.version_info >= (3, 11):
Expand Down Expand Up @@ -129,11 +133,13 @@ if sys.version_info >= (3, 10):

if sys.version_info >= (3, 11):
def linear_regression(
regressor: Sequence[_Number], dependent_variable: Sequence[_Number], /, *, proportional: bool = False
regressor: _SizedIterable[_Number], dependent_variable: _SizedIterable[_Number], /, *, proportional: bool = False
) -> LinearRegression: ...

elif sys.version_info >= (3, 10):
def linear_regression(regressor: Sequence[_Number], dependent_variable: Sequence[_Number], /) -> LinearRegression: ...
def linear_regression(
regressor: _SizedIterable[_Number], dependent_variable: _SizedIterable[_Number], /
) -> LinearRegression: ...

if sys.version_info >= (3, 13):
_Kernel: TypeAlias = Literal[
Expand Down