Skip to content

Commit

Permalink
Tidy code from review.
Browse files Browse the repository at this point in the history
  • Loading branch information
asford committed Jul 28, 2018
1 parent b1035ee commit 57b404f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/attr/_make.py
Expand Up @@ -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*
Expand All @@ -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(
Expand Down Expand Up @@ -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*
Expand Down
9 changes: 7 additions & 2 deletions tests/test_make.py
Expand Up @@ -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.
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -664,6 +665,7 @@ class C(object):
y = attr.ib()

c = C(1)

assert c.x == 0
assert c.y == 1

Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -738,6 +741,7 @@ class C:
C(0, y=1)

c = C(x=0, y=1)

assert c.x == 0
assert c.y == 1

Expand All @@ -759,6 +763,7 @@ class C(Base):
C(1)

c = C(x=0, y=1)

assert c.x == 0
assert c.y == 1

Expand Down

0 comments on commit 57b404f

Please sign in to comment.