-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
as designedNot a bug, working as intendedNot a bug, working as intended
Description
I just merged a PR over at typeshed to improve the stub for builtins.sum. The first draft of the PR proposed defining sum like this:
import sys
from typing import *
class _SupportsSum(Protocol):
def __add__(self, __x: Any) -> Any: ...
_SumT = TypeVar("_SumT", bound=_SupportsSum)
_SumS = TypeVar("_SumS", bound=_SupportsSum)
@overload
def sum(__iterable: Iterable[_SumT]) -> Any | Literal[0]: ...
if sys.version_info >= (3, 8):
@overload
def sum(__iterable: Iterable[_SumT], start: _SumS) -> _SumT | _SumS: ...
else:
@overload
def sum(__iterable: Iterable[_SumT], __start: _SumS) -> _SumT | _SumS: ...I think this should have triggered pyright's reportInvalidTypeVarUse check, as the TypeVar in the first overload is only used once. However, pyright reported no errors in our CI check.
(The PR was revised to correct this mistake before it was merged.)
Metadata
Metadata
Assignees
Labels
as designedNot a bug, working as intendedNot a bug, working as intended