Skip to content

Commit e79ac4f

Browse files
committed
Don't half-ass next_gen-ing
_funcs is terribly generic too
1 parent efd03b9 commit e79ac4f

3 files changed

Lines changed: 29 additions & 30 deletions

File tree

src/attr/_funcs.py

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from ._compat import get_generic_base
77
from ._make import _OBJ_SETATTR, NOTHING, fields
8-
from .exceptions import AttrsAttributeNotFoundError, NotAnAttrsClassError
8+
from .exceptions import AttrsAttributeNotFoundError
99

1010

1111
_ATOMIC_TYPES = frozenset(
@@ -379,32 +379,6 @@ def has(cls):
379379
return False
380380

381381

382-
def inspect(cls):
383-
"""
384-
Inspect the class and return its effective build parameters.
385-
386-
Warning:
387-
This feature is currently **experimental** and is not covered by our
388-
strict backwards-compatibility guarantees.
389-
390-
Args:
391-
cls: The *attrs*-decorated class to inspect.
392-
393-
Returns:
394-
The effective build parameters of the class.
395-
396-
Raises:
397-
NotAnAttrsClassError: If the class is not an *attrs*-decorated class.
398-
399-
.. versionadded:: 25.4.0
400-
"""
401-
try:
402-
return cls.__dict__["__attrs_props__"]
403-
except KeyError:
404-
msg = f"{cls!r} is not an attrs-decorated class."
405-
raise NotAnAttrsClassError(msg) from None
406-
407-
408382
def assoc(inst, **changes):
409383
"""
410384
Copy *inst* and apply *changes*.

src/attr/_next_gen.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
attrib,
1818
attrs,
1919
)
20-
from .exceptions import UnannotatedAttributeError
20+
from .exceptions import NotAnAttrsClassError, UnannotatedAttributeError
2121

2222

2323
def define(
@@ -646,3 +646,29 @@ def astuple(inst, *, recurse=True, filter=None):
646646
return _astuple(
647647
inst=inst, recurse=recurse, filter=filter, retain_collection_types=True
648648
)
649+
650+
651+
def inspect(cls):
652+
"""
653+
Inspect the class and return its effective build parameters.
654+
655+
Warning:
656+
This feature is currently **experimental** and is not covered by our
657+
strict backwards-compatibility guarantees.
658+
659+
Args:
660+
cls: The *attrs*-decorated class to inspect.
661+
662+
Returns:
663+
The effective build parameters of the class.
664+
665+
Raises:
666+
NotAnAttrsClassError: If the class is not an *attrs*-decorated class.
667+
668+
.. versionadded:: 25.4.0
669+
"""
670+
try:
671+
return cls.__dict__["__attrs_props__"]
672+
except KeyError:
673+
msg = f"{cls!r} is not an attrs-decorated class."
674+
raise NotAnAttrsClassError(msg) from None

src/attrs/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,8 @@
2222
resolve_types,
2323
validate,
2424
)
25-
from attr._funcs import inspect
2625
from attr._make import ClassProps
27-
from attr._next_gen import asdict, astuple
26+
from attr._next_gen import asdict, astuple, inspect
2827

2928
from . import converters, exceptions, filters, setters, validators
3029

0 commit comments

Comments
 (0)