You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/types.rst
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,12 +41,13 @@ Also, starting in Python 3.10 (:pep:`526`) **all** annotations will be string li
41
41
When this happens, ``attrs`` will simply put these string literals into the ``type`` attributes.
42
42
If you need to resolve these to real types, you can call `attr.resolve_types` which will update the attribute in place.
43
43
44
-
In practice though, types show their biggest usefulness in combination with tools likemypy_,pytype_ orpyright_ that have dedicated support for ``attrs`` classes.
44
+
In practice though, types show their biggest usefulness in combination with tools likemypy_,pytype_, orpyright_ that have dedicated support for ``attrs`` classes.
45
45
46
46
The addition of static types is certainly one of the most exciting features in the Python ecosystem and helps you writing *correct* and *verified self-documenting* code.
47
47
48
48
If you don't know where to start, Carl Meyer gave a great talk on `Type-checked Python in the Real World<https://www.youtube.com/watch?v=pMgmKJyWKn8>`_ at PyCon US 2018 that will help you to get started in no time.
49
49
50
+
50
51
mypy
51
52
----
52
53
@@ -83,27 +84,26 @@ and requires explicit type annotations using the :ref:`next-gen` or ``@attr.s(au
83
84
Given the following definition, ``pyright`` will generate static type signatures for ``SomeClass`` attribute access, ``__init__``, ``__eq__``, and comparison methods::
``dataclass_transform``-based types are supported provisionally as of ``pyright`` 1.1.135 and ``attrs`` 21.1.
93
94
Both the ``pyright``dataclass_transform_ specification and ``attrs`` implementation may changed in future versions.
94
95
95
96
The ``pyright`` inferred types are a subset of those supported by ``mypy``, including:
96
97
97
-
- The generated ``__init__`` signature only includes the attribute type annotations,
98
-
and does not include attribute ``converter`` types.
98
+
- The generated ``__init__`` signature only includes the attribute type annotations.
99
+
It currently does not include attribute ``converter`` types.
99
100
100
101
- The ``attr.frozen`` decorator is not typed with frozen attributes, which are properly typed via ``attr.define(frozen=True)``.
101
102
102
103
Your constructive feedback is welcome in both `attrs#795<https://github.com/python-attrs/attrs/issues/795>`_ and `pyright#1782<https://github.com/microsoft/pyright/discussions/1782>`_.