diff --git a/CHANGELOG.md b/CHANGELOG.md index 61758b5d..58cfe562 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -285,7 +285,7 @@ See https://github.com/python-attrs/attrs/blob/main/.github/CONTRIBUTING.md#chan See the [new docs on comparison](https://www.attrs.org/en/stable/comparison.html) for more details. [#787](https://github.com/python-attrs/attrs/issues/787) -- Added **provisional** support for static typing in `pyright` via the [dataclass_transforms specification](https://github.com/microsoft/pyright/blob/main/specs/dataclass_transforms.md). +- Added **provisional** support for static typing in `pyright` via [PEP 681](https://peps.python.org/pep-0681/). Both the `pyright` specification and `attrs` implementation may change in future versions of both projects. 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). diff --git a/docs/conf.py b/docs/conf.py index ef5c4197..b02f07e5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,9 +20,6 @@ r"https://github.com/.*/(issues|pull)/\d+", # Rate limits and the latest tag is missing anyways on release. "https://github.com/python-attrs/attrs/tree/.*", - # It never finds the anchor even though it's there. - "https://github.com/microsoft/pyright/blob/main/specs/" - "dataclass_transforms.md#attrs", ] # In nitpick mode (-n), still ignore any of the following "broken" references diff --git a/docs/extending.md b/docs/extending.md index 84bd9bfe..b2f96fb9 100644 --- a/docs/extending.md +++ b/docs/extending.md @@ -94,7 +94,7 @@ You can only use this trick to tell *Mypy* that a class is actually an *attrs* c ### Pyright -Generic decorator wrapping is supported in [*Pyright*](https://github.com/microsoft/pyright) via their [`dataclass_transform`] specification. +Generic decorator wrapping is supported in [*Pyright*](https://github.com/microsoft/pyright) via `dataclass_transform` / {pep}`689`. For a custom wrapping of the form: @@ -118,11 +118,6 @@ def __dataclass_transform__( def custom_define(f): ... ``` -:::{warning} -`dataclass_transform` is supported **provisionally** as of `pyright` 1.1.135. - -Both the *Pyright* [`dataclass_transform`] specification and *attrs* implementation may change in future versions. -::: ## Types @@ -332,5 +327,3 @@ It has the signature >>> json.dumps(data) '{"dt": "2020-05-04T13:37:00"}' ``` - -[`dataclass_transform`]: https://github.com/microsoft/pyright/blob/main/specs/dataclass_transforms.md diff --git a/docs/types.md b/docs/types.md index b1c14dba..494693bd 100644 --- a/docs/types.md +++ b/docs/types.md @@ -73,7 +73,7 @@ class SomeClass: ## Pyright -*attrs* provides support for [*Pyright*] though the [`dataclass_transform`] specification. +*attrs* provides support for [*Pyright*] through the `dataclass_transform` / {pep}`681` specification. This provides static type inference for a subset of *attrs* equivalent to standard-library {mod}`dataclasses`, and requires explicit type annotations using the {func}`attrs.define` or `@attr.s(auto_attribs=True)` API. @@ -94,13 +94,10 @@ The *Pyright* inferred types are a tiny subset of those supported by *Mypy*, inc - The `attrs.frozen` decorator is not typed with frozen attributes, which are properly typed via `attrs.define(frozen=True)`. - A [full list](https://github.com/microsoft/pyright/blob/main/specs/dataclass_transforms.md#attrs) of limitations and incompatibilities can be found in *Pyright*'s repository. - 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). Generally speaking, the decision on improving *attrs* support in *Pyright* is entirely Microsoft's prerogative, though. ::: -[`dataclass_transform`]: https://github.com/microsoft/pyright/blob/main/specs/dataclass_transforms.md [*Mypy*]: http://mypy-lang.org [*Pyright*]: https://github.com/microsoft/pyright [*pytype*]: https://google.github.io/pytype/