diff --git a/src/attr/_make.py b/src/attr/_make.py index 8fabf9ea8..efff8e781 100644 --- a/src/attr/_make.py +++ b/src/attr/_make.py @@ -155,7 +155,7 @@ def attrib( ``Attribute.type``. :param kw_only: Make this attribute keyword-only (Python 3+) in the generated ``__init__`` (if ``init`` is ``False``, this - parameter is simply ignored). + parameter is ignored). .. versionadded:: 15.2.0 *convert* .. versionadded:: 16.3.0 *metadata* @@ -168,7 +168,7 @@ def attrib( *convert* to achieve consistency with other noun-based arguments. .. versionadded:: 18.1.0 ``factory=f`` is syntactic sugar for ``default=attr.Factory(f)``. - .. versionadded:: 18.2.0 *kw_only* + .. versionadded:: 18.2.0 *kw_only* """ if hash is not None and hash is not True and hash is not False: raise TypeError( @@ -762,7 +762,7 @@ def attrs( .. _`PEP 526`: https://www.python.org/dev/peps/pep-0526/ :param bool kw_only: Make all attributes keyword-only (Python 3+) in the generated ``__init__`` (if ``init`` is ``False``, this - parameter is simply ignored). + parameter is ignored). .. versionadded:: 16.0.0 *slots* diff --git a/tests/test_make.py b/tests/test_make.py index e48c50e6a..e56321160 100644 --- a/tests/test_make.py +++ b/tests/test_make.py @@ -289,7 +289,7 @@ class C(object): def test_kw_only(self): """ Converts all attributes, including superclass attributes, if `kw_only` - is provided. Therefor, `kw_only` allows attributes with defaults to + is provided. Therefore, `kw_only` allows attributes with defaults to preceed mandatory attributes. Updates in the subclass *don't* affect the superclass attributes. @@ -307,6 +307,7 @@ class C(B): y = attr.ib() attrs, super_attrs, _ = _transform_attrs(C, None, False, True) + assert len(attrs) == 3 assert len(super_attrs) == 1 @@ -628,7 +629,7 @@ class C(object): x = attr.ib(factory=Factory(list)) -@pytest.mark.skipif(PY2, reason="keyword-only arguments is PY3-only.") +@pytest.mark.skipif(PY2, reason="keyword-only arguments are PY3-only.") class TestKeywordOnlyAttributes(object): """ Tests for keyword-only attributes. @@ -664,6 +665,7 @@ class C(object): y = attr.ib() c = C(1) + assert c.x == 0 assert c.y == 1 @@ -696,6 +698,7 @@ class C(object): with pytest.raises(ValueError) as e: _transform_attrs(C, None, False, False) + assert ( "Non keyword-only attributes are not allowed after a " "keyword-only attribute. Attribute in question: Attribute" @@ -738,6 +741,7 @@ class C: C(0, y=1) c = C(x=0, y=1) + assert c.x == 0 assert c.y == 1 @@ -759,6 +763,7 @@ class C(Base): C(1) c = C(x=0, y=1) + assert c.x == 0 assert c.y == 1