Remove _add_init
More concretely: move it to tests. It was dead code for a while however its
unittests are still valuable as the exercise quite a bit of _make_init.
diff --git a/src/attr/_make.py b/src/attr/_make.py
index 043edef..827175a 100644
--- a/src/attr/_make.py
+++ b/src/attr/_make.py
@@ -1308,22 +1308,6 @@
return __init__
-def _add_init(cls, frozen):
- """
- Add a __init__ method to *cls*. If *frozen* is True, make it immutable.
- """
- cls.__init__ = _make_init(
- cls.__attrs_attrs__,
- getattr(cls, "__attrs_post_init__", False),
- frozen,
- _is_slot_cls(cls),
- cache_hash=False,
- base_attr_map={},
- is_exc=False,
- )
- return cls
-
-
def fields(cls):
"""
Return the tuple of ``attrs`` attributes for a class.
diff --git a/tests/test_dunders.py b/tests/test_dunders.py
index 545a2b3..94fdff8 100644
--- a/tests/test_dunders.py
+++ b/tests/test_dunders.py
@@ -17,8 +17,9 @@
from attr._make import (
NOTHING,
Factory,
- _add_init,
_add_repr,
+ _is_slot_cls,
+ _make_init,
_Nothing,
fields,
make_class,
@@ -49,6 +50,25 @@
)
+def _add_init(cls, frozen):
+ """
+ Add a __init__ method to *cls*. If *frozen* is True, make it immutable.
+
+ This function used to be part of _make. It wasn't used anymore however
+ the tests for it are still useful to test the behavior of _make_init.
+ """
+ cls.__init__ = _make_init(
+ cls.__attrs_attrs__,
+ getattr(cls, "__attrs_post_init__", False),
+ frozen,
+ _is_slot_cls(cls),
+ cache_hash=False,
+ base_attr_map={},
+ is_exc=False,
+ )
+ return cls
+
+
class InitC(object):
__attrs_attrs__ = [simple_attr("a"), simple_attr("b")]