Skip to content

Commit

Permalink
Add kw_only to type stubs.
Browse files Browse the repository at this point in the history
  • Loading branch information
asford committed Jul 24, 2018
1 parent 52d2948 commit 0d488a9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/attr/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Attribute(Generic[_T]):
converter: Optional[_ConverterType[_T]]
metadata: Dict[Any, Any]
type: Optional[Type[_T]]
kw_onlly: bool
def __lt__(self, x: Attribute) -> bool: ...
def __le__(self, x: Attribute) -> bool: ...
def __gt__(self, x: Attribute) -> bool: ...
Expand Down Expand Up @@ -99,6 +100,7 @@ def attrib(
type: None = ...,
converter: None = ...,
factory: None = ...,
kw_only: bool = ...,
) -> Any: ...

# This form catches an explicit None or no default and infers the type from the other arguments.
Expand All @@ -115,6 +117,7 @@ def attrib(
type: Optional[Type[_T]] = ...,
converter: Optional[_ConverterType[_T]] = ...,
factory: Optional[Callable[[], _T]] = ...,
kw_only: bool = ...,
) -> _T: ...

# This form catches an explicit default argument.
Expand All @@ -131,6 +134,7 @@ def attrib(
type: Optional[Type[_T]] = ...,
converter: Optional[_ConverterType[_T]] = ...,
factory: Optional[Callable[[], _T]] = ...,
kw_only: bool = ...,
) -> _T: ...

# This form covers type=non-Type: e.g. forward references (str), Any
Expand All @@ -147,6 +151,7 @@ def attrib(
type: object = ...,
converter: Optional[_ConverterType[_T]] = ...,
factory: Optional[Callable[[], _T]] = ...,
kw_only: bool = ...,
) -> Any: ...
@overload
def attrs(
Expand All @@ -161,6 +166,7 @@ def attrs(
frozen: bool = ...,
str: bool = ...,
auto_attribs: bool = ...,
kw_only: bool = ...,
) -> _C: ...
@overload
def attrs(
Expand All @@ -175,6 +181,7 @@ def attrs(
frozen: bool = ...,
str: bool = ...,
auto_attribs: bool = ...,
kw_only: bool = ...,
) -> Callable[[_C], _C]: ...

# TODO: add support for returning NamedTuple from the mypy plugin
Expand All @@ -200,6 +207,7 @@ def make_class(
frozen: bool = ...,
str: bool = ...,
auto_attribs: bool = ...,
kw_only: bool = ...,
) -> type: ...

# _funcs --
Expand Down

0 comments on commit 0d488a9

Please sign in to comment.