Skip to content

Commit 738ee63

Browse files
authored
Add missing cmp_using to stub files (#949)
* Add missing cmp_using to stub files Signed-off-by: Hynek Schlawack <[email protected]> * Add newsfragment
1 parent 0f08b84 commit 738ee63

File tree

6 files changed

+8
-4
lines changed

6 files changed

+8
-4
lines changed

changelog.d/949.change.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Added missing stub for ``attr(s).cmp_using()``.

docs/comparison.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ It is then used as a key function like you may know from `sorted`:
5050
This is especially useful when you have fields with objects that have atypical comparison properties.
5151
Common examples of such objects are `NumPy arrays <https://github.com/python-attrs/attrs/issues/435>`_.
5252

53-
To save you unnecessary boilerplate, ``attrs`` comes with the `attr.cmp_using` helper to create such functions.
53+
To save you unnecessary boilerplate, ``attrs`` comes with the `attrs.cmp_using` helper to create such functions.
5454
For NumPy arrays it would look like this::
5555

5656
import numpy

src/attr/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ from . import filters as filters
2323
from . import setters as setters
2424
from . import validators as validators
2525
from ._version_info import VersionInfo
26+
from ._cmp import cmp_using as cmp_using
2627

2728
__version__: str
2829
__version_info__: VersionInfo
@@ -51,7 +52,6 @@ _OnSetAttrArgType = Union[
5152
_FieldTransformer = Callable[
5253
[type, List[Attribute[Any]]], List[Attribute[Any]]
5354
]
54-
_CompareWithType = Callable[[Any, Any], bool]
5555
# FIXME: in reality, if multiple validators are passed they must be in a list
5656
# or tuple, but those are invariant and so would prevent subtypes of
5757
# _ValidatorType from working when passed in a list or tuple.

src/attr/_cmp.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from typing import Type
1+
from typing import Any, Callable, Optional, Type
22

3-
from . import _CompareWithType
3+
_CompareWithType = Callable[[Any, Any], bool]
44

55
def cmp_using(
66
eq: Optional[_CompareWithType],

src/attrs/__init__.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ from attr import __version_info__ as __version_info__
2323
from attr import _FilterType
2424
from attr import assoc as assoc
2525
from attr import Attribute as Attribute
26+
from attr import cmp_using as cmp_using
2627
from attr import converters as converters
2728
from attr import define as define
2829
from attr import evolve as evolve

tests/typing_example.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ def accessing_from_attr() -> None:
403403
attr.filters.include
404404
attr.setters.frozen
405405
attr.validators.and_
406+
attr.cmp_using
406407

407408

408409
def accessing_from_attrs() -> None:
@@ -414,3 +415,4 @@ def accessing_from_attrs() -> None:
414415
attrs.filters.include
415416
attrs.setters.frozen
416417
attrs.validators.and_
418+
attrs.cmp_using

0 commit comments

Comments
 (0)