diff --git a/stdlib/2and3/decimal.pyi b/stdlib/2and3/decimal.pyi index 91271981c4e0..799894fc1c43 100644 --- a/stdlib/2and3/decimal.pyi +++ b/stdlib/2and3/decimal.pyi @@ -35,7 +35,8 @@ if sys.version_info >= (3,): MIN_ETINY: int class DecimalException(ArithmeticError): - def handle(self, context: Context, *args: Any) -> Optional[Decimal]: ... + if sys.version_info < (3,): + def handle(self, context: Context, *args: Any) -> Optional[Decimal]: ... class Clamped(DecimalException): ... @@ -64,14 +65,14 @@ class Underflow(Inexact, Rounded, Subnormal): ... if sys.version_info >= (3,): class FloatOperation(DecimalException, TypeError): ... -def setcontext(context: Context) -> None: ... +def setcontext(__context: Context) -> None: ... def getcontext() -> Context: ... def localcontext(ctx: Optional[Context] = ...) -> _ContextManager: ... class Decimal(object): def __new__(cls: Type[_DecimalT], value: _DecimalNew = ..., context: Optional[Context] = ...) -> _DecimalT: ... @classmethod - def from_float(cls, f: float) -> Decimal: ... + def from_float(cls, __f: float) -> Decimal: ... if sys.version_info >= (3,): def __bool__(self) -> bool: ... else: @@ -83,7 +84,7 @@ class Decimal(object): def compare(self, other: _Decimal, context: Optional[Context] = ...) -> Decimal: ... def __hash__(self) -> int: ... def as_tuple(self) -> DecimalTuple: ... - if sys.version_info >= (3,): + if sys.version_info >= (3, 6): def as_integer_ratio(self) -> Tuple[int, int]: ... def to_eng_string(self, context: Optional[Context] = ...) -> str: ... diff --git a/stdlib/3/_decimal.pyi b/stdlib/3/_decimal.pyi new file mode 100644 index 000000000000..e38f3cf07653 --- /dev/null +++ b/stdlib/3/_decimal.pyi @@ -0,0 +1,2 @@ + +from decimal import * diff --git a/stdlib/3/_pydecimal.pyi b/stdlib/3/_pydecimal.pyi new file mode 100644 index 000000000000..4f742239336c --- /dev/null +++ b/stdlib/3/_pydecimal.pyi @@ -0,0 +1,4 @@ + +# This is a slight lie, the implementations aren't exactly identical +# However, in all likelihood, the differences are inconsequential +from decimal import * diff --git a/tests/stubtest_whitelists/py35.txt b/tests/stubtest_whitelists/py35.txt index 661bac3eeec5..8b4c1387b38f 100644 --- a/tests/stubtest_whitelists/py35.txt +++ b/tests/stubtest_whitelists/py35.txt @@ -21,7 +21,6 @@ codecs.StreamRecoder.seek collections.Reversible collections.UserString.maketrans ctypes.CDLL.__init__ -decimal.Decimal.as_integer_ratio fractions.Fraction.__new__ # private _normalize param was made keyword-only in Python 3.6 gettext.NullTranslations.npgettext gettext.NullTranslations.pgettext diff --git a/tests/stubtest_whitelists/py38.txt b/tests/stubtest_whitelists/py38.txt index eb6912e2e679..81e76b189bf2 100644 --- a/tests/stubtest_whitelists/py38.txt +++ b/tests/stubtest_whitelists/py38.txt @@ -66,8 +66,6 @@ copy.PyStringMap dataclasses.dataclass dataclasses.field dataclasses.replace -decimal.Decimal.from_float -decimal.setcontext email.message.MIMEPart.as_string enum.Enum._generate_next_value_ functools.partialmethod.__get__ diff --git a/tests/stubtest_whitelists/py3_common.txt b/tests/stubtest_whitelists/py3_common.txt index d58ac3cfcb0b..2fddcd44283c 100644 --- a/tests/stubtest_whitelists/py3_common.txt +++ b/tests/stubtest_whitelists/py3_common.txt @@ -154,7 +154,6 @@ curses.COLS curses.LINES dbm.error dbm.ndbm -decimal.DecimalException.handle difflib.SequenceMatcher.__init__ distutils.archive_util.make_archive distutils.archive_util.make_tarball @@ -523,6 +522,7 @@ zlib.compressobj # ========== # Whitelist entries that cannot or should not be fixed # ========== +_pydecimal.* # See comments in file ast.NodeVisitor.visit_\w+ # Methods are discovered dynamically, see #3796 # Weird special builtins that are typed as functions, but aren't functions builtins.copyright