mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-04 18:43:23 +08:00
apply black and isort (#4287)
* apply black and isort * move some type ignores
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from typing import Any, Dict, NewType, Tuple, Type, TypeVar
|
||||
|
||||
from typing import Type, TypeVar, Tuple, Any, Dict, NewType
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_T = TypeVar("_T")
|
||||
|
||||
# TODO: Change the return into a NewType bound to int after pytype/#597
|
||||
def get_cache_token() -> object: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from typing import Any, Callable, ClassVar, Generic, Iterator, Mapping, TypeVar
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class ContextVar(Generic[_T]):
|
||||
def __init__(self, name: str, *, default: _T = ...) -> None: ...
|
||||
|
||||
@@ -1,32 +1,26 @@
|
||||
from typing import overload, Any, Callable, Dict, Generic, Iterable, List, Mapping, Optional, Tuple, Type, TypeVar, Union
|
||||
from typing import Any, Callable, Dict, Generic, Iterable, List, Mapping, Optional, Tuple, Type, TypeVar, Union, overload
|
||||
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class _MISSING_TYPE: ...
|
||||
MISSING: _MISSING_TYPE
|
||||
|
||||
MISSING: _MISSING_TYPE
|
||||
@overload
|
||||
def asdict(obj: Any) -> Dict[str, Any]: ...
|
||||
@overload
|
||||
def asdict(obj: Any, *, dict_factory: Callable[[List[Tuple[str, Any]]], _T]) -> _T: ...
|
||||
|
||||
@overload
|
||||
def astuple(obj: Any) -> Tuple[Any, ...]: ...
|
||||
@overload
|
||||
def astuple(obj: Any, *, tuple_factory: Callable[[List[Any]], _T]) -> _T: ...
|
||||
|
||||
|
||||
@overload
|
||||
def dataclass(_cls: Type[_T]) -> Type[_T]: ...
|
||||
|
||||
@overload
|
||||
def dataclass(_cls: None) -> Callable[[Type[_T]], Type[_T]]: ...
|
||||
|
||||
@overload
|
||||
def dataclass(*, init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ...,
|
||||
unsafe_hash: bool = ..., frozen: bool = ...) -> Callable[[Type[_T]], Type[_T]]: ...
|
||||
|
||||
def dataclass(
|
||||
*, init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ..., unsafe_hash: bool = ..., frozen: bool = ...
|
||||
) -> Callable[[Type[_T]], Type[_T]]: ...
|
||||
|
||||
class Field(Generic[_T]):
|
||||
name: str
|
||||
@@ -39,36 +33,54 @@ class Field(Generic[_T]):
|
||||
compare: bool
|
||||
metadata: Mapping[str, Any]
|
||||
|
||||
|
||||
# NOTE: Actual return type is 'Field[_T]', but we want to help type checkers
|
||||
# to understand the magic that happens at runtime.
|
||||
@overload # `default` and `default_factory` are optional and mutually exclusive.
|
||||
def field(*, default: _T,
|
||||
init: bool = ..., repr: bool = ..., hash: Optional[bool] = ..., compare: bool = ...,
|
||||
metadata: Optional[Mapping[str, Any]] = ...) -> _T: ...
|
||||
|
||||
def field(
|
||||
*,
|
||||
default: _T,
|
||||
init: bool = ...,
|
||||
repr: bool = ...,
|
||||
hash: Optional[bool] = ...,
|
||||
compare: bool = ...,
|
||||
metadata: Optional[Mapping[str, Any]] = ...,
|
||||
) -> _T: ...
|
||||
@overload
|
||||
def field(*, default_factory: Callable[[], _T],
|
||||
init: bool = ..., repr: bool = ..., hash: Optional[bool] = ..., compare: bool = ...,
|
||||
metadata: Optional[Mapping[str, Any]] = ...) -> _T: ...
|
||||
|
||||
def field(
|
||||
*,
|
||||
default_factory: Callable[[], _T],
|
||||
init: bool = ...,
|
||||
repr: bool = ...,
|
||||
hash: Optional[bool] = ...,
|
||||
compare: bool = ...,
|
||||
metadata: Optional[Mapping[str, Any]] = ...,
|
||||
) -> _T: ...
|
||||
@overload
|
||||
def field(*,
|
||||
init: bool = ..., repr: bool = ..., hash: Optional[bool] = ..., compare: bool = ...,
|
||||
metadata: Optional[Mapping[str, Any]] = ...) -> Any: ...
|
||||
|
||||
|
||||
def field(
|
||||
*,
|
||||
init: bool = ...,
|
||||
repr: bool = ...,
|
||||
hash: Optional[bool] = ...,
|
||||
compare: bool = ...,
|
||||
metadata: Optional[Mapping[str, Any]] = ...,
|
||||
) -> Any: ...
|
||||
def fields(class_or_instance: Any) -> Tuple[Field[Any], ...]: ...
|
||||
|
||||
def is_dataclass(obj: Any) -> bool: ...
|
||||
|
||||
class FrozenInstanceError(AttributeError): ...
|
||||
|
||||
class InitVar(Generic[_T]): ...
|
||||
|
||||
def make_dataclass(cls_name: str, fields: Iterable[Union[str, Tuple[str, type], Tuple[str, type, Field[Any]]]], *,
|
||||
bases: Tuple[type, ...] = ..., namespace: Optional[Dict[str, Any]] = ...,
|
||||
init: bool = ..., repr: bool = ..., eq: bool = ..., order: bool = ..., unsafe_hash: bool = ...,
|
||||
frozen: bool = ...) -> type: ...
|
||||
|
||||
def make_dataclass(
|
||||
cls_name: str,
|
||||
fields: Iterable[Union[str, Tuple[str, type], Tuple[str, type, Field[Any]]]],
|
||||
*,
|
||||
bases: Tuple[type, ...] = ...,
|
||||
namespace: Optional[Dict[str, Any]] = ...,
|
||||
init: bool = ...,
|
||||
repr: bool = ...,
|
||||
eq: bool = ...,
|
||||
order: bool = ...,
|
||||
unsafe_hash: bool = ...,
|
||||
frozen: bool = ...,
|
||||
) -> type: ...
|
||||
def replace(obj: _T, **changes: Any) -> _T: ...
|
||||
|
||||
Reference in New Issue
Block a user