8000 Ensures overloads are ordered from narrow to broad by Michael0x2a · Pull Request #2138 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Ensures overloads are ordered from narrow to broad #2138

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 17, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert change to attr
  • Loading branch information
Michael0x2a committed May 16, 2018
commit 1f44ff6f64d0a94e7e847481dfe4b98bd958891c
82 changes: 41 additions & 41 deletions third_party/2and3/attr/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,7 @@ class Attribute(Generic[_T]):
# attr(validator=<some callable>) -> Whatever the callable expects.
# This makes this type of assignments possible:
# x: int = attr(8)

# This form catches explicit None or no default but with no other arguments returns Any.
@overload
def attrib(default: None = ...,
validator: None = ...,
repr: bool = ...,
cmp: bool = ...,
hash: Optional[bool] = ...,
init: bool = ...,
convert: None = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: None = ...,
converter: None = ...,
factory: None = ...,
) -> Any: ...
#
# This form catches an explicit None or no default and infers the type from the other arguments.
@overload
def attrib(default: None = ...,
Expand Down Expand Up @@ -112,6 +98,20 @@ def attrib(default: _T,
converter: Optional[_ConverterType[_T]] = ...,
factory: Optional[Callable[[], _T]] = ...,
) -> _T: ...
# This form catches explicit None or no default but with no other arguments returns Any.
@overload
def attrib(default: None = ...,
validator: None = ...,
repr: bool = ...,
cmp: bool = ...,
hash: Optional[bool] = ...,
init: bool = ...,
convert: None = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: None = ...,
converter: None = ...,
factory: None = ...,
) -> Any: ...
# This form covers type=non-Type: e.g. forward references (str), Any
@overload
def attrib(default: Optional[_T] = ...,
Expand Down Expand Up @@ -216,19 +216,6 @@ def get_run_validators() -> bool: ...
# dataclass = attrs # Technically, partial(attrs, auto_attribs=True) ;)


@overload
def ib(default: None = ...,
validator: None = ...,
repr: bool = ...,
cmp: bool = ...,
hash: Optional[bool] = ...,
init: bool = ...,
convert: None = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: None = ...,
converter: None = ...,
factory: None = ...,
) -> Any: ...
@overload
def ib(default: None = ...,
validator: Optional[_ValidatorArgType[_T]] = ...,
Expand Down Expand Up @@ -256,6 +243,19 @@ def ib(default: _T,
factory: Optional[Callable[[], _T]] = ...,
) -> _T: ...
@overload
def ib(default: None = ...,
validator: None = ...,
repr: bool = ...,
cmp: bool = ...,
hash: Optional[bool] = ...,
init: bool = ...,
convert: None = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: None = ...,
converter: None = ...,
factory: None = ...,
) -> Any: ...
@overload
def ib(default: Optional[_T] = ...,
validator: Optional[_ValidatorArgType[_T]] = ...,
repr: bool = ...,
Expand All @@ -270,19 +270,6 @@ def ib(default: Optional[_T] = ...,
) -> Any: ...

@overload
def attr(default: None = ...,
validator: None = ...,
repr: bool = ...,
cmp: bool = ...,
hash: Optional[bool] = ...,
init: bool = ...,
convert: None = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: None = ...,
converter: None = ...,
factory: None = ...,
) -> Any: ...
@overload
def attr(default: None = ...,
validator: Optional[_ValidatorArgType[_T]] = ...,
repr: bool = ...,
Expand All @@ -309,6 +296,19 @@ def attr(default: _T,
factory: Optional[Callable[[], _T]] = ...,
) -> _T: ...
@overload
def attr(default: None = ...,
validator: None = ...,
repr: bool = ...,
cmp: bool = ...,
hash: Optional[bool] = ...,
init: bool = ...,
convert: None = ...,
metadata: Optional[Mapping[Any, Any]] = ...,
type: None = ...,
converter: None = ...,
factory: None = ...,
) -> Any: ...
@overload
def attr(default: Optional[_T] = ...,
validator: Optional[_ValidatorArgType[_T]] = ...,
repr: bool = ...,
Expand Down
0