From f9cb7c3ed4f75a6fbd3ff67df2a93d6d9837d979 Mon Sep 17 00:00:00 2001 From: Akuli Date: Tue, 8 Mar 2022 23:38:31 +0200 Subject: [PATCH] Use Literal for statistics.quantiles() (#7463) I'm going to merge; I think this is consistent with what we've done with e.g. the `byteorder` argument for `int.from_bytes` :) --- stdlib/statistics.pyi | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stdlib/statistics.pyi b/stdlib/statistics.pyi index 1a194dee7..879ea3c74 100644 --- a/stdlib/statistics.pyi +++ b/stdlib/statistics.pyi @@ -3,6 +3,7 @@ from _typeshed import Self, SupportsRichComparisonT from decimal import Decimal from fractions import Fraction from typing import Any, Hashable, Iterable, NamedTuple, Sequence, SupportsFloat, TypeVar, Union +from typing_extensions import Literal if sys.version_info >= (3, 10): __all__ = [ @@ -102,7 +103,9 @@ def pstdev(data: Iterable[_NumberT], mu: _NumberT | None = ...) -> _NumberT: ... def pvariance(data: Iterable[_NumberT], mu: _NumberT | None = ...) -> _NumberT: ... if sys.version_info >= (3, 8): - def quantiles(data: Iterable[_NumberT], *, n: int = ..., method: str = ...) -> list[_NumberT]: ... + def quantiles( + data: Iterable[_NumberT], *, n: int = ..., method: Literal["inclusive", "exclusive"] = ... + ) -> list[_NumberT]: ... def stdev(data: Iterable[_NumberT], xbar: _NumberT | None = ...) -> _NumberT: ... def variance(data: Iterable[_NumberT], xbar: _NumberT | None = ...) -> _NumberT: ...