Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Core

>>> import attr
>>> @attr.s
... class C(object):
... class C:
... x = attr.ib()
>>> attr.fields(C).x
Attribute(name='x', default=NOTHING, validator=None, repr=True, eq=True, eq_key=None, order=True, order_key=None, hash=None, init=True, metadata=mappingproxy({}), type=None, converter=None, kw_only=False, inherited=False, on_setattr=None)
Expand Down Expand Up @@ -101,7 +101,7 @@ Core
.. doctest::

>>> @attr.s
... class C(object):
... class C:
... x = attr.ib(default=attr.Factory(list))
... y = attr.ib(default=attr.Factory(
... lambda self: set(self.x),
Expand Down Expand Up @@ -132,11 +132,11 @@ Classic

>>> import attr
>>> @attr.s
... class C(object):
... class C:
... _private = attr.ib()
>>> C(private=42)
C(_private=42)
>>> class D(object):
>>> class D:
... def __init__(self, x):
... self.x = x
>>> D(1)
Expand Down Expand Up @@ -171,7 +171,7 @@ Classic
.. doctest::

>>> @attr.s
... class C(object):
... class C:
... x = attr.ib()
... y = attr.ib()
... @x.validator
Expand Down Expand Up @@ -242,7 +242,7 @@ Helpers
.. doctest::

>>> @attr.s
... class C(object):
... class C:
... x = attr.ib()
... y = attr.ib()
>>> attrs.fields(C)
Expand All @@ -263,7 +263,7 @@ Helpers
.. doctest::

>>> @attr.s
... class C(object):
... class C:
... x = attr.ib()
... y = attr.ib()
>>> attrs.fields_dict(C)
Expand All @@ -284,7 +284,7 @@ Helpers
.. doctest::

>>> @attr.s
... class C(object):
... class C:
... pass
>>> attr.has(C)
True
Expand Down Expand Up @@ -467,7 +467,7 @@ All objects from ``attrs.validators`` are also available from ``attr.validators`
.. doctest::

>>> @attrs.define
... class C(object):
... class C:
... x = attrs.field(validator=attr.validators.le(42))
>>> C(42)
C(x=42)
Expand Down Expand Up @@ -732,7 +732,7 @@ All objects from ``attrs.converters`` are also available from ``attr.converters`
.. doctest::

>>> @attr.s
... class C(object):
... class C:
... x = attr.ib(converter=attr.converters.optional(int))
>>> C(None)
C(x=None)
Expand All @@ -747,7 +747,7 @@ All objects from ``attrs.converters`` are also available from ``attr.converters`
.. doctest::

>>> @attr.s
... class C(object):
... class C:
... x = attr.ib(
... converter=attr.converters.default_if_none("")
... )
Expand All @@ -762,7 +762,7 @@ All objects from ``attrs.converters`` are also available from ``attr.converters`
.. doctest::

>>> @attr.s
... class C(object):
... class C:
... x = attr.ib(
... converter=attr.converters.to_bool
... )
Expand Down Expand Up @@ -836,7 +836,7 @@ It behaves similarly to `sys.version_info` and is an instance of `VersionInfo`:
>>> cmp_off == {"eq": False}
True
>>> @attr.s(**cmp_off)
... class C(object):
... class C:
... pass


Expand Down
4 changes: 2 additions & 2 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ For that, `attrs.asdict` offers a callback that decides whether an attribute sho
.. doctest::

>>> @define
... class User(object):
... class User:
... email: str
... password: str

Expand Down Expand Up @@ -486,7 +486,7 @@ Types

>>> import attr
>>> @attr.s
... class C(object):
... class C:
... x = attr.ib(type=int)
>>> fields(C).x.type
<class 'int'>
Expand Down
2 changes: 1 addition & 1 deletion docs/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Passing complex objects into ``__init__`` and then using them to derive data for

So assuming you use an ORM and want to extract 2D points from a row object, do not write code like this::

class Point(object):
class Point:
def __init__(self, database_row):
self.x = database_row.x
self.y = database_row.y
Expand Down
2 changes: 1 addition & 1 deletion docs/names.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ But overall, ``attrs`` in this shape was a **huge** success -- especially after
Being able to just write::

@attr.s
class Point(object):
class Point:
x = attr.ib()
y = attr.ib()

Expand Down
2 changes: 1 addition & 1 deletion docs/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ To mypy, this code is equivalent to the one above:
.. code-block:: python

@attr.s
class SomeClass(object):
class SomeClass:
a_number = attr.ib(default=42) # type: int
list_of_numbers = attr.ib(factory=list, type=list[int])

Expand Down
6 changes: 3 additions & 3 deletions docs/why.rst
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ To bring it into perspective, the equivalent of
.. doctest::

>>> @attr.s
... class SmartClass(object):
... class SmartClass:
... a = attr.ib()
... b = attr.ib()
>>> SmartClass(1, 2)
Expand All @@ -212,7 +212,7 @@ is roughly

.. doctest::

>>> class ArtisanalClass(object):
>>> class ArtisanalClass:
... def __init__(self, a, b):
... self.a = a
... self.b = b
Expand Down Expand Up @@ -272,7 +272,7 @@ You can freely choose which features you want and disable those that you want mo
.. doctest::

>>> @attr.s(repr=False)
... class SmartClass(object):
... class SmartClass:
... a = attr.ib()
... b = attr.ib()
...
Expand Down
10 changes: 5 additions & 5 deletions tests/test_mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@
main: |
import attr
@attr.s
class C(object):
class C:
x: int = attr.ib(default=1)
y: int = attr.ib()
@y.default
Expand All @@ -700,7 +700,7 @@
main: |
import attr
@attr.s
class C(object):
class C:
x = attr.ib()
@x.validator
def check(self, attribute, value):
Expand Down Expand Up @@ -944,7 +944,7 @@
main: |
import attr
@attr.s
class C(object):
class C:
_x = attr.ib(init=False, default=42)
C()
C(_x=42) # E: Unexpected keyword argument "_x" for "C"
Expand Down Expand Up @@ -1228,7 +1228,7 @@

import attr
@attr.s
class C(object):
class C:
x: int = attr.ib(default=1)
y: int = attr.ib()
@y.default
Expand All @@ -1243,7 +1243,7 @@

import attr
@attr.s
class C(object):
class C:
x = attr.ib()
@x.validator
def check(self, attribute, value):
Expand Down