Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf41db43

Browse files
committed
Unpin pyright & minor docs polish
ref#796
1 parent16f7a0d commitf41db43

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

‎docs/extending.rst‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ An example for that is the package `environ-config <https://github.com/hynek/env
4747
Another common use case is to overwrite ``attrs``'s defaults.
4848

4949
Mypy
50-
************
50+
^^^^
5151

5252
Unfortunately, decorator wrapping currently `confuses<https://github.com/python/mypy/issues/5406>`_ mypy's ``attrs`` plugin.
5353
At the moment, the best workaround is to hold your nose, write a fake mypy plugin, and mutate a bunch of global variables::
@@ -90,9 +90,9 @@ Then tell mypy about your plugin using your project's ``mypy.ini``:
9090
You can only use this trick to tell mypy that a class is actually an ``attrs`` class.
9191

9292
Pyright
93-
*************
93+
^^^^^^^
9494

95-
Generic decorator wrapping is supported in ``pyright`` viathe provisionaldataclass_transform_ specification.
95+
Generic decorator wrapping is supported in `pyright<https://github.com/microsoft/pyright>`_ viatheirdataclass_transform_ specification.
9696

9797
For a custom wrapping of the form::
9898

@@ -112,11 +112,12 @@ This is implemented via a ``__dataclass_transform__`` type decorator in the cust
112112
@__dataclass_transform__(field_descriptors=(attr.attrib, attr.field))
113113
def custom_define(f): ...
114114

115-
..note::
115+
..warning::
116+
117+
``dataclass_transform`` is supported **provisionally** as of ``pyright`` 1.1.135.
116118

117-
``dataclass_transform``is supported provisionally as of ``pyright``1.1.135.
119+
Both the ``pyright``dataclass_transform_ specification and ``attrs``implementation may change in future versions.
118120

119-
Both the ``pyright``dataclass_transform_ specification and ``attrs`` implementation may changed in future versions.
120121

121122
Types
122123
-----
@@ -306,4 +307,4 @@ It has the signature
306307

307308
*****
308309

309-
.. _dataclass_transform:https://github.com/microsoft/pyright/blob/1.1.135/specs/dataclass_transforms.md
310+
.. _dataclass_transform:https://github.com/microsoft/pyright/blob/master/specs/dataclass_transforms.md

‎docs/types.rst‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ Also, starting in Python 3.10 (:pep:`526`) **all** annotations will be string li
4141
When this happens, ``attrs`` will simply put these string literals into the ``type`` attributes.
4242
If you need to resolve these to real types, you can call `attr.resolve_types` which will update the attribute in place.
4343

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.
4545

4646
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.
4747

4848
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.
4949

50+
5051
mypy
5152
----
5253

@@ -83,27 +84,26 @@ and requires explicit type annotations using the :ref:`next-gen` or ``@attr.s(au
8384
Given the following definition, ``pyright`` will generate static type signatures for ``SomeClass`` attribute access, ``__init__``, ``__eq__``, and comparison methods::
8485

8586
@attr.define
86-
class SomeClass(object):
87+
class SomeClass:
8788
a_number: int = 42
8889
list_of_numbers: typing.List[int] = attr.field(factory=list)
8990

90-
..note::
91+
..warning::
9192

9293
``dataclass_transform``-based types are supported provisionally as of ``pyright`` 1.1.135 and ``attrs`` 21.1.
9394
Both the ``pyright``dataclass_transform_ specification and ``attrs`` implementation may changed in future versions.
9495

9596
The ``pyright`` inferred types are a subset of those supported by ``mypy``, including:
9697

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.
99100

100101
- The ``attr.frozen`` decorator is not typed with frozen attributes, which are properly typed via ``attr.define(frozen=True)``.
101102

102103
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>`_.
103104

104-
*****
105105

106106
.. _mypy:http://mypy-lang.org
107107
.. _pytype:https://google.github.io/pytype/
108108
.. _pyright:https://github.com/microsoft/pyright
109-
.. _dataclass_transform:https://github.com/microsoft/pyright/blob/1.1.135/specs/dataclass_transforms.md
109+
.. _dataclass_transform:https://github.com/microsoft/pyright/blob/master/specs/dataclass_transforms.md

‎tox.ini‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,5 +133,5 @@ basepython = python3.9
133133
deps = nodeenv
134134
commands =
135135
nodeenv --prebuilt --node=lts --force {envdir}
136-
npm install -g --no-package-lock --no-save pyright@1.1.135
136+
npm install -g --no-package-lock --no-save pyright
137137
pytest tests/test_pyright.py -vv

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp