mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-15 08:17:07 +08:00
Use PEP 585 syntax in @python2/_ast, convert more TypeVars to _typeshed.Self, & # noqa a SQLAlchemy line (#6954)
* Manual fixes for `_ast` and `SQLAlchemy` * Change more `TypeVar`s to `Self`, using script
This commit is contained in:
@@ -82,13 +82,13 @@ class object:
|
||||
class staticmethod(object): # Special, only valid as a decorator.
|
||||
__func__: Callable[..., Any]
|
||||
def __init__(self, f: Callable[..., Any]) -> None: ...
|
||||
def __new__(cls: type[_T], *args: Any, **kwargs: Any) -> _T: ...
|
||||
def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ...
|
||||
def __get__(self, obj: _T, type: type[_T] | None = ...) -> Callable[..., Any]: ...
|
||||
|
||||
class classmethod(object): # Special, only valid as a decorator.
|
||||
__func__: Callable[..., Any]
|
||||
def __init__(self, f: Callable[..., Any]) -> None: ...
|
||||
def __new__(cls: type[_T], *args: Any, **kwargs: Any) -> _T: ...
|
||||
def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ...
|
||||
def __get__(self, obj: _T, type: type[_T] | None = ...) -> Callable[..., Any]: ...
|
||||
|
||||
class type(object):
|
||||
@@ -127,9 +127,9 @@ class super(object):
|
||||
|
||||
class int:
|
||||
@overload
|
||||
def __new__(cls: type[_T], x: Text | bytes | SupportsInt | _SupportsIndex | _SupportsTrunc = ...) -> _T: ...
|
||||
def __new__(cls: type[Self], x: Text | bytes | SupportsInt | _SupportsIndex | _SupportsTrunc = ...) -> Self: ...
|
||||
@overload
|
||||
def __new__(cls: type[_T], x: Text | bytes | bytearray, base: int) -> _T: ...
|
||||
def __new__(cls: type[Self], x: Text | bytes | bytearray, base: int) -> Self: ...
|
||||
@property
|
||||
def real(self) -> int: ...
|
||||
@property
|
||||
@@ -191,7 +191,7 @@ class int:
|
||||
def __index__(self) -> int: ...
|
||||
|
||||
class float:
|
||||
def __new__(cls: type[_T], x: SupportsFloat | _SupportsIndex | Text | bytes | bytearray = ...) -> _T: ...
|
||||
def __new__(cls: type[Self], x: SupportsFloat | _SupportsIndex | Text | bytes | bytearray = ...) -> Self: ...
|
||||
def as_integer_ratio(self) -> tuple[int, int]: ...
|
||||
def hex(self) -> str: ...
|
||||
def is_integer(self) -> bool: ...
|
||||
@@ -241,9 +241,9 @@ class float:
|
||||
|
||||
class complex:
|
||||
@overload
|
||||
def __new__(cls: type[_T], real: float = ..., imag: float = ...) -> _T: ...
|
||||
def __new__(cls: type[Self], real: float = ..., imag: float = ...) -> Self: ...
|
||||
@overload
|
||||
def __new__(cls: type[_T], real: str | SupportsComplex | _SupportsIndex) -> _T: ...
|
||||
def __new__(cls: type[Self], real: str | SupportsComplex | _SupportsIndex) -> Self: ...
|
||||
@property
|
||||
def real(self) -> float: ...
|
||||
@property
|
||||
@@ -548,7 +548,7 @@ class memoryview(Sized, Container[str]):
|
||||
|
||||
@final
|
||||
class bool(int):
|
||||
def __new__(cls: type[_T], __o: object = ...) -> _T: ...
|
||||
def __new__(cls: type[Self], __o: object = ...) -> Self: ...
|
||||
@overload
|
||||
def __and__(self, x: bool) -> bool: ...
|
||||
@overload
|
||||
@@ -587,7 +587,7 @@ class slice(object):
|
||||
def indices(self, len: int) -> tuple[int, int, int]: ...
|
||||
|
||||
class tuple(Sequence[_T_co], Generic[_T_co]):
|
||||
def __new__(cls: type[_T], iterable: Iterable[_T_co] = ...) -> _T: ...
|
||||
def __new__(cls: type[Self], iterable: Iterable[_T_co] = ...) -> Self: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __contains__(self, x: object) -> bool: ...
|
||||
@overload
|
||||
@@ -664,7 +664,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def __init__(self, map: SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT) -> None: ...
|
||||
@overload
|
||||
def __init__(self, iterable: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
|
||||
def __new__(cls: type[_T1], *args: Any, **kwargs: Any) -> _T1: ...
|
||||
def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ...
|
||||
def has_key(self, k: _KT) -> bool: ...
|
||||
def clear(self) -> None: ...
|
||||
def copy(self) -> dict[_KT, _VT]: ...
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
import typing
|
||||
|
||||
__version__: str
|
||||
PyCF_ONLY_AST: int
|
||||
_identifier = str
|
||||
|
||||
class AST:
|
||||
_attributes: typing.Tuple[str, ...]
|
||||
_fields: typing.Tuple[str, ...]
|
||||
_attributes: tuple[str, ...]
|
||||
_fields: tuple[str, ...]
|
||||
def __init__(self, *args, **kwargs) -> None: ...
|
||||
|
||||
class mod(AST): ...
|
||||
|
||||
class Module(mod):
|
||||
body: typing.List[stmt]
|
||||
body: list[stmt]
|
||||
|
||||
class Interactive(mod):
|
||||
body: typing.List[stmt]
|
||||
body: list[stmt]
|
||||
|
||||
class Expression(mod):
|
||||
body: expr
|
||||
|
||||
class Suite(mod):
|
||||
body: typing.List[stmt]
|
||||
body: list[stmt]
|
||||
|
||||
class stmt(AST):
|
||||
lineno: int
|
||||
@@ -30,23 +28,23 @@ class stmt(AST):
|
||||
class FunctionDef(stmt):
|
||||
name: _identifier
|
||||
args: arguments
|
||||
body: typing.List[stmt]
|
||||
decorator_list: typing.List[expr]
|
||||
body: list[stmt]
|
||||
decorator_list: list[expr]
|
||||
|
||||
class ClassDef(stmt):
|
||||
name: _identifier
|
||||
bases: typing.List[expr]
|
||||
body: typing.List[stmt]
|
||||
decorator_list: typing.List[expr]
|
||||
bases: list[expr]
|
||||
body: list[stmt]
|
||||
decorator_list: list[expr]
|
||||
|
||||
class Return(stmt):
|
||||
value: expr | None
|
||||
|
||||
class Delete(stmt):
|
||||
targets: typing.List[expr]
|
||||
targets: list[expr]
|
||||
|
||||
class Assign(stmt):
|
||||
targets: typing.List[expr]
|
||||
targets: list[expr]
|
||||
value: expr
|
||||
|
||||
class AugAssign(stmt):
|
||||
@@ -56,29 +54,29 @@ class AugAssign(stmt):
|
||||
|
||||
class Print(stmt):
|
||||
dest: expr | None
|
||||
values: typing.List[expr]
|
||||
values: list[expr]
|
||||
nl: bool
|
||||
|
||||
class For(stmt):
|
||||
target: expr
|
||||
iter: expr
|
||||
body: typing.List[stmt]
|
||||
orelse: typing.List[stmt]
|
||||
body: list[stmt]
|
||||
orelse: list[stmt]
|
||||
|
||||
class While(stmt):
|
||||
test: expr
|
||||
body: typing.List[stmt]
|
||||
orelse: typing.List[stmt]
|
||||
body: list[stmt]
|
||||
orelse: list[stmt]
|
||||
|
||||
class If(stmt):
|
||||
test: expr
|
||||
body: typing.List[stmt]
|
||||
orelse: typing.List[stmt]
|
||||
body: list[stmt]
|
||||
orelse: list[stmt]
|
||||
|
||||
class With(stmt):
|
||||
context_expr: expr
|
||||
optional_vars: expr | None
|
||||
body: typing.List[stmt]
|
||||
body: list[stmt]
|
||||
|
||||
class Raise(stmt):
|
||||
type: expr | None
|
||||
@@ -86,24 +84,24 @@ class Raise(stmt):
|
||||
tback: expr | None
|
||||
|
||||
class TryExcept(stmt):
|
||||
body: typing.List[stmt]
|
||||
handlers: typing.List[ExceptHandler]
|
||||
orelse: typing.List[stmt]
|
||||
body: list[stmt]
|
||||
handlers: list[ExceptHandler]
|
||||
orelse: list[stmt]
|
||||
|
||||
class TryFinally(stmt):
|
||||
body: typing.List[stmt]
|
||||
finalbody: typing.List[stmt]
|
||||
body: list[stmt]
|
||||
finalbody: list[stmt]
|
||||
|
||||
class Assert(stmt):
|
||||
test: expr
|
||||
msg: expr | None
|
||||
|
||||
class Import(stmt):
|
||||
names: typing.List[alias]
|
||||
names: list[alias]
|
||||
|
||||
class ImportFrom(stmt):
|
||||
module: _identifier | None
|
||||
names: typing.List[alias]
|
||||
names: list[alias]
|
||||
level: int | None
|
||||
|
||||
class Exec(stmt):
|
||||
@@ -112,7 +110,7 @@ class Exec(stmt):
|
||||
locals: expr | None
|
||||
|
||||
class Global(stmt):
|
||||
names: typing.List[_identifier]
|
||||
names: list[_identifier]
|
||||
|
||||
class Expr(stmt):
|
||||
value: expr
|
||||
@@ -130,7 +128,7 @@ class Slice(slice):
|
||||
step: expr | None
|
||||
|
||||
class ExtSlice(slice):
|
||||
dims: typing.List[slice]
|
||||
dims: list[slice]
|
||||
|
||||
class Index(slice):
|
||||
value: expr
|
||||
@@ -143,7 +141,7 @@ class expr(AST):
|
||||
|
||||
class BoolOp(expr):
|
||||
op: boolop
|
||||
values: typing.List[expr]
|
||||
values: list[expr]
|
||||
|
||||
class BinOp(expr):
|
||||
left: expr
|
||||
@@ -164,41 +162,41 @@ class IfExp(expr):
|
||||
orelse: expr
|
||||
|
||||
class Dict(expr):
|
||||
keys: typing.List[expr]
|
||||
values: typing.List[expr]
|
||||
keys: list[expr]
|
||||
values: list[expr]
|
||||
|
||||
class Set(expr):
|
||||
elts: typing.List[expr]
|
||||
elts: list[expr]
|
||||
|
||||
class ListComp(expr):
|
||||
elt: expr
|
||||
generators: typing.List[comprehension]
|
||||
generators: list[comprehension]
|
||||
|
||||
class SetComp(expr):
|
||||
elt: expr
|
||||
generators: typing.List[comprehension]
|
||||
generators: list[comprehension]
|
||||
|
||||
class DictComp(expr):
|
||||
key: expr
|
||||
value: expr
|
||||
generators: typing.List[comprehension]
|
||||
generators: list[comprehension]
|
||||
|
||||
class GeneratorExp(expr):
|
||||
elt: expr
|
||||
generators: typing.List[comprehension]
|
||||
generators: list[comprehension]
|
||||
|
||||
class Yield(expr):
|
||||
value: expr | None
|
||||
|
||||
class Compare(expr):
|
||||
left: expr
|
||||
ops: typing.List[cmpop]
|
||||
comparators: typing.List[expr]
|
||||
ops: list[cmpop]
|
||||
comparators: list[expr]
|
||||
|
||||
class Call(expr):
|
||||
func: expr
|
||||
args: typing.List[expr]
|
||||
keywords: typing.List[keyword]
|
||||
args: list[expr]
|
||||
keywords: list[keyword]
|
||||
starargs: expr | None
|
||||
kwargs: expr | None
|
||||
|
||||
@@ -226,11 +224,11 @@ class Name(expr):
|
||||
ctx: expr_context
|
||||
|
||||
class List(expr):
|
||||
elts: typing.List[expr]
|
||||
elts: list[expr]
|
||||
ctx: expr_context
|
||||
|
||||
class Tuple(expr):
|
||||
elts: typing.List[expr]
|
||||
elts: list[expr]
|
||||
ctx: expr_context
|
||||
|
||||
class expr_context(AST): ...
|
||||
@@ -276,22 +274,22 @@ class NotIn(cmpop): ...
|
||||
class comprehension(AST):
|
||||
target: expr
|
||||
iter: expr
|
||||
ifs: typing.List[expr]
|
||||
ifs: list[expr]
|
||||
|
||||
class excepthandler(AST): ...
|
||||
|
||||
class ExceptHandler(excepthandler):
|
||||
type: expr | None
|
||||
name: expr | None
|
||||
body: typing.List[stmt]
|
||||
body: list[stmt]
|
||||
lineno: int
|
||||
col_offset: int
|
||||
|
||||
class arguments(AST):
|
||||
args: typing.List[expr]
|
||||
args: list[expr]
|
||||
vararg: _identifier | None
|
||||
kwarg: _identifier | None
|
||||
defaults: typing.List[expr]
|
||||
defaults: list[expr]
|
||||
|
||||
class keyword(AST):
|
||||
arg: _identifier
|
||||
|
||||
@@ -82,13 +82,13 @@ class object:
|
||||
class staticmethod(object): # Special, only valid as a decorator.
|
||||
__func__: Callable[..., Any]
|
||||
def __init__(self, f: Callable[..., Any]) -> None: ...
|
||||
def __new__(cls: type[_T], *args: Any, **kwargs: Any) -> _T: ...
|
||||
def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ...
|
||||
def __get__(self, obj: _T, type: type[_T] | None = ...) -> Callable[..., Any]: ...
|
||||
|
||||
class classmethod(object): # Special, only valid as a decorator.
|
||||
__func__: Callable[..., Any]
|
||||
def __init__(self, f: Callable[..., Any]) -> None: ...
|
||||
def __new__(cls: type[_T], *args: Any, **kwargs: Any) -> _T: ...
|
||||
def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ...
|
||||
def __get__(self, obj: _T, type: type[_T] | None = ...) -> Callable[..., Any]: ...
|
||||
|
||||
class type(object):
|
||||
@@ -127,9 +127,9 @@ class super(object):
|
||||
|
||||
class int:
|
||||
@overload
|
||||
def __new__(cls: type[_T], x: Text | bytes | SupportsInt | _SupportsIndex | _SupportsTrunc = ...) -> _T: ...
|
||||
def __new__(cls: type[Self], x: Text | bytes | SupportsInt | _SupportsIndex | _SupportsTrunc = ...) -> Self: ...
|
||||
@overload
|
||||
def __new__(cls: type[_T], x: Text | bytes | bytearray, base: int) -> _T: ...
|
||||
def __new__(cls: type[Self], x: Text | bytes | bytearray, base: int) -> Self: ...
|
||||
@property
|
||||
def real(self) -> int: ...
|
||||
@property
|
||||
@@ -191,7 +191,7 @@ class int:
|
||||
def __index__(self) -> int: ...
|
||||
|
||||
class float:
|
||||
def __new__(cls: type[_T], x: SupportsFloat | _SupportsIndex | Text | bytes | bytearray = ...) -> _T: ...
|
||||
def __new__(cls: type[Self], x: SupportsFloat | _SupportsIndex | Text | bytes | bytearray = ...) -> Self: ...
|
||||
def as_integer_ratio(self) -> tuple[int, int]: ...
|
||||
def hex(self) -> str: ...
|
||||
def is_integer(self) -> bool: ...
|
||||
@@ -241,9 +241,9 @@ class float:
|
||||
|
||||
class complex:
|
||||
@overload
|
||||
def __new__(cls: type[_T], real: float = ..., imag: float = ...) -> _T: ...
|
||||
def __new__(cls: type[Self], real: float = ..., imag: float = ...) -> Self: ...
|
||||
@overload
|
||||
def __new__(cls: type[_T], real: str | SupportsComplex | _SupportsIndex) -> _T: ...
|
||||
def __new__(cls: type[Self], real: str | SupportsComplex | _SupportsIndex) -> Self: ...
|
||||
@property
|
||||
def real(self) -> float: ...
|
||||
@property
|
||||
@@ -548,7 +548,7 @@ class memoryview(Sized, Container[str]):
|
||||
|
||||
@final
|
||||
class bool(int):
|
||||
def __new__(cls: type[_T], __o: object = ...) -> _T: ...
|
||||
def __new__(cls: type[Self], __o: object = ...) -> Self: ...
|
||||
@overload
|
||||
def __and__(self, x: bool) -> bool: ...
|
||||
@overload
|
||||
@@ -587,7 +587,7 @@ class slice(object):
|
||||
def indices(self, len: int) -> tuple[int, int, int]: ...
|
||||
|
||||
class tuple(Sequence[_T_co], Generic[_T_co]):
|
||||
def __new__(cls: type[_T], iterable: Iterable[_T_co] = ...) -> _T: ...
|
||||
def __new__(cls: type[Self], iterable: Iterable[_T_co] = ...) -> Self: ...
|
||||
def __len__(self) -> int: ...
|
||||
def __contains__(self, x: object) -> bool: ...
|
||||
@overload
|
||||
@@ -664,7 +664,7 @@ class dict(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def __init__(self, map: SupportsKeysAndGetItem[_KT, _VT], **kwargs: _VT) -> None: ...
|
||||
@overload
|
||||
def __init__(self, iterable: Iterable[tuple[_KT, _VT]], **kwargs: _VT) -> None: ...
|
||||
def __new__(cls: type[_T1], *args: Any, **kwargs: Any) -> _T1: ...
|
||||
def __new__(cls: type[Self], *args: Any, **kwargs: Any) -> Self: ...
|
||||
def has_key(self, k: _KT) -> bool: ...
|
||||
def clear(self) -> None: ...
|
||||
def copy(self) -> dict[_KT, _VT]: ...
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import sys
|
||||
from _typeshed import Self
|
||||
from array import array
|
||||
from typing import (
|
||||
Any,
|
||||
@@ -74,15 +75,15 @@ class _CData(metaclass=_CDataMeta):
|
||||
_b_needsfree_: bool = ...
|
||||
_objects: Mapping[Any, int] | None = ...
|
||||
@classmethod
|
||||
def from_buffer(cls: type[_CT], source: _WritableBuffer, offset: int = ...) -> _CT: ...
|
||||
def from_buffer(cls: type[Self], source: _WritableBuffer, offset: int = ...) -> Self: ...
|
||||
@classmethod
|
||||
def from_buffer_copy(cls: type[_CT], source: _ReadOnlyBuffer, offset: int = ...) -> _CT: ...
|
||||
def from_buffer_copy(cls: type[Self], source: _ReadOnlyBuffer, offset: int = ...) -> Self: ...
|
||||
@classmethod
|
||||
def from_address(cls: type[_CT], address: int) -> _CT: ...
|
||||
def from_address(cls: type[Self], address: int) -> Self: ...
|
||||
@classmethod
|
||||
def from_param(cls: type[_CT], obj: Any) -> _UnionT[_CT, _CArgObject]: ...
|
||||
@classmethod
|
||||
def in_dll(cls: type[_CT], library: CDLL, name: str) -> _CT: ...
|
||||
def in_dll(cls: type[Self], library: CDLL, name: str) -> Self: ...
|
||||
|
||||
class _CanCastTo(_CData): ...
|
||||
class _PointerLike(_CanCastTo): ...
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
from _typeshed import Self
|
||||
from time import struct_time
|
||||
from typing import AnyStr, ClassVar, SupportsAbs, TypeVar, Union, overload
|
||||
|
||||
_S = TypeVar("_S")
|
||||
from typing import AnyStr, ClassVar, SupportsAbs, Union, overload
|
||||
|
||||
_Text = Union[str, unicode]
|
||||
|
||||
@@ -20,13 +19,13 @@ class date:
|
||||
min: ClassVar[date]
|
||||
max: ClassVar[date]
|
||||
resolution: ClassVar[timedelta]
|
||||
def __new__(cls: type[_S], year: int, month: int, day: int) -> _S: ...
|
||||
def __new__(cls: type[Self], year: int, month: int, day: int) -> Self: ...
|
||||
@classmethod
|
||||
def fromtimestamp(cls: type[_S], __timestamp: float) -> _S: ...
|
||||
def fromtimestamp(cls: type[Self], __timestamp: float) -> Self: ...
|
||||
@classmethod
|
||||
def today(cls: type[_S]) -> _S: ...
|
||||
def today(cls: type[Self]) -> Self: ...
|
||||
@classmethod
|
||||
def fromordinal(cls: type[_S], n: int) -> _S: ...
|
||||
def fromordinal(cls: type[Self], n: int) -> Self: ...
|
||||
@property
|
||||
def year(self) -> int: ...
|
||||
@property
|
||||
@@ -60,8 +59,13 @@ class time:
|
||||
max: ClassVar[time]
|
||||
resolution: ClassVar[timedelta]
|
||||
def __new__(
|
||||
cls: type[_S], hour: int = ..., minute: int = ..., second: int = ..., microsecond: int = ..., tzinfo: _tzinfo | None = ...
|
||||
) -> _S: ...
|
||||
cls: type[Self],
|
||||
hour: int = ...,
|
||||
minute: int = ...,
|
||||
second: int = ...,
|
||||
microsecond: int = ...,
|
||||
tzinfo: _tzinfo | None = ...,
|
||||
) -> Self: ...
|
||||
@property
|
||||
def hour(self) -> int: ...
|
||||
@property
|
||||
@@ -95,7 +99,7 @@ class timedelta(SupportsAbs[timedelta]):
|
||||
max: ClassVar[timedelta]
|
||||
resolution: ClassVar[timedelta]
|
||||
def __new__(
|
||||
cls: type[_S],
|
||||
cls: type[Self],
|
||||
days: float = ...,
|
||||
seconds: float = ...,
|
||||
microseconds: float = ...,
|
||||
@@ -103,7 +107,7 @@ class timedelta(SupportsAbs[timedelta]):
|
||||
minutes: float = ...,
|
||||
hours: float = ...,
|
||||
weeks: float = ...,
|
||||
) -> _S: ...
|
||||
) -> Self: ...
|
||||
@property
|
||||
def days(self) -> int: ...
|
||||
@property
|
||||
@@ -139,7 +143,7 @@ class datetime(date):
|
||||
max: ClassVar[datetime]
|
||||
resolution: ClassVar[timedelta]
|
||||
def __new__(
|
||||
cls: type[_S],
|
||||
cls: type[Self],
|
||||
year: int,
|
||||
month: int,
|
||||
day: int,
|
||||
@@ -148,7 +152,7 @@ class datetime(date):
|
||||
second: int = ...,
|
||||
microsecond: int = ...,
|
||||
tzinfo: _tzinfo | None = ...,
|
||||
) -> _S: ...
|
||||
) -> Self: ...
|
||||
@property
|
||||
def year(self) -> int: ...
|
||||
@property
|
||||
@@ -166,21 +170,21 @@ class datetime(date):
|
||||
@property
|
||||
def tzinfo(self) -> _tzinfo | None: ...
|
||||
@classmethod
|
||||
def fromtimestamp(cls: type[_S], t: float, tz: _tzinfo | None = ...) -> _S: ...
|
||||
def fromtimestamp(cls: type[Self], t: float, tz: _tzinfo | None = ...) -> Self: ...
|
||||
@classmethod
|
||||
def utcfromtimestamp(cls: type[_S], t: float) -> _S: ...
|
||||
def utcfromtimestamp(cls: type[Self], t: float) -> Self: ...
|
||||
@classmethod
|
||||
def today(cls: type[_S]) -> _S: ...
|
||||
def today(cls: type[Self]) -> Self: ...
|
||||
@classmethod
|
||||
def fromordinal(cls: type[_S], n: int) -> _S: ...
|
||||
def fromordinal(cls: type[Self], n: int) -> Self: ...
|
||||
@overload
|
||||
@classmethod
|
||||
def now(cls: type[_S], tz: None = ...) -> _S: ...
|
||||
def now(cls: type[Self], tz: None = ...) -> Self: ...
|
||||
@overload
|
||||
@classmethod
|
||||
def now(cls, tz: _tzinfo) -> datetime: ...
|
||||
@classmethod
|
||||
def utcnow(cls: type[_S]) -> _S: ...
|
||||
def utcnow(cls: type[Self]) -> Self: ...
|
||||
@classmethod
|
||||
def combine(cls, date: _date, time: _time) -> datetime: ...
|
||||
def strftime(self, fmt: _Text) -> str: ...
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from _typeshed import Self
|
||||
from types import TracebackType
|
||||
from typing import Any, Container, NamedTuple, Sequence, Text, TypeVar, Union
|
||||
from typing import Any, Container, NamedTuple, Sequence, Text, Union
|
||||
|
||||
_Decimal = Union[Decimal, int]
|
||||
_DecimalNew = Union[Decimal, float, Text, tuple[int, Sequence[int], int]]
|
||||
_ComparableNum = Union[Decimal, float]
|
||||
_DecimalT = TypeVar("_DecimalT", bound=Decimal)
|
||||
|
||||
class DecimalTuple(NamedTuple):
|
||||
sign: int
|
||||
@@ -41,7 +41,7 @@ def getcontext() -> Context: ...
|
||||
def localcontext(ctx: Context | None = ...) -> _ContextManager: ...
|
||||
|
||||
class Decimal(object):
|
||||
def __new__(cls: type[_DecimalT], value: _DecimalNew = ..., context: Context | None = ...) -> _DecimalT: ...
|
||||
def __new__(cls: type[Self], value: _DecimalNew = ..., context: Context | None = ...) -> Self: ...
|
||||
@classmethod
|
||||
def from_float(cls, __f: float) -> Decimal: ...
|
||||
def __nonzero__(self) -> bool: ...
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
from _typeshed import Self
|
||||
from decimal import Decimal
|
||||
from numbers import Integral, Rational, Real
|
||||
from typing import TypeVar, Union, overload
|
||||
from typing import Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
_ComparableNum = Union[int, float, Decimal, Real]
|
||||
_T = TypeVar("_T")
|
||||
|
||||
@overload
|
||||
def gcd(a: int, b: int) -> int: ...
|
||||
@@ -18,10 +18,10 @@ def gcd(a: Integral, b: Integral) -> Integral: ...
|
||||
class Fraction(Rational):
|
||||
@overload
|
||||
def __new__(
|
||||
cls: type[_T], numerator: int | Rational = ..., denominator: int | Rational | None = ..., *, _normalize: bool = ...
|
||||
) -> _T: ...
|
||||
cls: type[Self], numerator: int | Rational = ..., denominator: int | Rational | None = ..., *, _normalize: bool = ...
|
||||
) -> Self: ...
|
||||
@overload
|
||||
def __new__(cls: type[_T], __value: float | Decimal | str, *, _normalize: bool = ...) -> _T: ...
|
||||
def __new__(cls: type[Self], __value: float | Decimal | str, *, _normalize: bool = ...) -> Self: ...
|
||||
@classmethod
|
||||
def from_float(cls, f: float) -> Fraction: ...
|
||||
@classmethod
|
||||
|
||||
Reference in New Issue
Block a user