mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-25 13:21:11 +08:00
Add _pydecimal and _decimal stubs (#4003)
This commit is contained in:
@@ -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: ...
|
||||
|
||||
2
stdlib/3/_decimal.pyi
Normal file
2
stdlib/3/_decimal.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
from decimal import *
|
||||
4
stdlib/3/_pydecimal.pyi
Normal file
4
stdlib/3/_pydecimal.pyi
Normal file
@@ -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 *
|
||||
@@ -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
|
||||
|
||||
@@ -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__
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user