From 9e72a7fd0c54b4c0a72ca0bbeb82ef717366da68 Mon Sep 17 00:00:00 2001 From: Rebecca Chen Date: Sat, 15 Sep 2018 09:12:52 -0700 Subject: [PATCH] Fix the return type of decimal.Decimal.__new__. (#2458) --- stdlib/2and3/decimal.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stdlib/2and3/decimal.pyi b/stdlib/2and3/decimal.pyi index d40eaad8a..0eebc2e6f 100644 --- a/stdlib/2and3/decimal.pyi +++ b/stdlib/2and3/decimal.pyi @@ -2,7 +2,7 @@ import numbers import sys from types import TracebackType from typing import ( - Any, Dict, NamedTuple, Optional, Sequence, Tuple, Union, Text, Type, Container, List, + Any, Container, Dict, List, NamedTuple, Optional, Sequence, Text, Tuple, Type, TypeVar, Union, ) _Decimal = Union[Decimal, int] @@ -11,6 +11,7 @@ if sys.version_info >= (3,): _ComparableNum = Union[Decimal, float, numbers.Rational] else: _ComparableNum = Union[Decimal, float] +_DecimalT = TypeVar('_DecimalT', bound=Decimal) DecimalTuple = NamedTuple('DecimalTuple', [('sign', int), @@ -68,7 +69,7 @@ def getcontext() -> Context: ... def localcontext(ctx: Optional[Context] = ...) -> _ContextManager: ... class Decimal(object): - def __new__(cls, value: _DecimalNew = ..., context: Optional[Context] = ...) -> None: ... + def __new__(cls: Type[_DecimalT], value: _DecimalNew = ..., context: Optional[Context] = ...) -> _DecimalT: ... @classmethod def from_float(cls, f: float) -> Decimal: ... if sys.version_info >= (3,):