Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve (de)serialization and validation capabilities #653

Merged
merged 2 commits into from
Oct 15, 2020

Conversation

sscherfke
Copy link
Contributor

@sscherfke sscherfke commented Jun 17, 2020

Improve (de)serialization and validation capabilities by adding hooks that can automatically update a class’ attributes and that can change the way how objects are serialized by asdict().

See: #649

Pull Request Check List

This is just a friendly reminder about the most common mistakes. Please make sure that you tick all boxes. But please read our contribution guide at least once, it will save you unnecessary review cycles!

If an item doesn't apply to your pull request, check it anyway to make it apparent that there's nothing left to do.

  • Added tests for changed code.
  • New features have been added to our Hypothesis testing strategy.
  • Changes or additions to public APIs are reflected in our type stubs (files ending in .pyi).
    • ...and used in the stub test file tests/typing_example.py.
  • Updated documentation for changed code.
    • New functions/classes have to be added to docs/api.rst by hand.
    • Changes to the signature of @attr.s() have to be added by hand too.
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives. Find the appropriate next version in our __init__.py file.
  • Documentation in .rst files is written using semantic newlines.
  • Changes (and possible deprecations) have news fragments in changelog.d.

If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!

Comment on lines 2186 to 2193
def hook(name, ca, type):
ca.converter = type

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hrm… if I were writing a hook like this, I'd be type hinting everything, and the type of ca here is _CountingAttr, which is private. That seems like a problem.

IIRC we've avoided making _CountingAttr public, so this API would require us to at least define an interface, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that’s true. I also stumbled upon this when I was writing the docstring. Making an Interface seems like a reasonable idea. We wouldn’t to expose the actual _CountingAttr than but mypy would be happy nonetheless.

@sscherfke
Copy link
Contributor Author

I have a lot more uncommited code, but some (important) parts of it require at least Python 3.6.

When are you planning to drop support for Python 2 (and maybe even 3.5)? This would make a few things easier and if that’s not too far into the future, I would gladly wait a little. :)

@wsanchez
Copy link

When are you planning to drop support for Python 2 (and maybe even 3.5)? This would make a few things easier and if that’s not too far into the future, I would gladly wait a little. :)

I suggest you file an Issue called "[RFC] Drop support for Python 2" and have that discussion there, as it's not specific to this ticket. (And perhaps another for 3.5.)

@hynek
Copy link
Member

hynek commented Jun 18, 2020

I'm sorry I'm offline for the next week, but there's been a feature request asking for _CountingAttr to become public already so this might be two birds with one stone.

As for Python 2: https://www.attrs.org/en/stable/python-2.html

As much as I don't like it, it's one of our main features over dataclasses ATM.

Once we go Python 3-only, it will definitely not be 3.5. :)

@sscherfke
Copy link
Contributor Author

What is your preferred approach for tests that run (and parse) only with python 3.6 and above?

@hynek
Copy link
Member

hynek commented Jul 8, 2020

if sys.version_info[:2] < (3, 6):

@sscherfke sscherfke force-pushed the master branch 2 times, most recently from 8fdcdce to 30e4359 Compare July 9, 2020 21:10
@sscherfke
Copy link
Contributor Author

This PR will only focus on the hooks. I have removed the converters and validators and will re-propose them in another PR when this one is accepted.

@sscherfke sscherfke force-pushed the master branch 2 times, most recently from 871729f to 6c0872c Compare July 12, 2020 09:22
@sscherfke sscherfke changed the title WIP: Improve (de)serialization and validation capabilities Improve (de)serialization and validation capabilities Jul 12, 2020
@sscherfke sscherfke changed the title Improve (de)serialization and validation capabilities WIP: Improve (de)serialization and validation capabilities Jul 12, 2020
@sscherfke
Copy link
Contributor Author

_CountingAttr (or an interface for it) need to be made public for this PR.

What would be your prefered approach? Create a new Interface that _CountingAttr inherits or rename _CountingAttr to CountingAttr? Should also be imported in __init__.py in that case?

@wsanchez
Copy link

_CountingAttr (or an interface for it) need to be made public for this PR.

What would be your prefered approach? Create a new Interface that _CountingAttr inherits or rename _CountingAttr to CountingAttr? Should also be imported in __init__.py in that case?

Again, we've resisted making _CountingAttr in the past because it's not an API we want to commit to long-term, so an interface that is limited to what we are willing to support seems best, leaving _CountingAttr itself as an implementation detail.

That assumes that @hynek is amenable to the resulting public interface.

@hynek
Copy link
Member

hynek commented Jul 13, 2020

The main issue here is that I don't want it to be "counting" anymore if not necessary (ordered dicts), cf #643. I guess we'll have to extract a sub-interface?

@sscherfke
Copy link
Contributor Author

An Interface would suffice since it will (at least in this PR) only be used for documentation and (mypy) typing. I can try to extract an Interface.

@sscherfke
Copy link
Contributor Author

Hm, _CountingAttr is so "simple" and specific, that I don’t know which attributes/meths to extract into an interface.

@wsanchez
Copy link

Hm, _CountingAttr is so "simple" and specific, that I don’t know which attributes/meths to extract into an interface.

I'd start with: what exactly is the minimum needed for this PR to function?

@sscherfke
Copy link
Contributor Author

I only want to add a converter to the attrib, but instances of _CountingAttr (I’d call the interface MutableAttr since it is, in contrast to Attribute, mutable) are passed to the hook so it would not be very long-sighted to only add the converter attribute to the interface. I think at least converter, metadata, validator() and default() should be made public. Changing the other attributes in the hook might not make too much sense.

@hynek
Copy link
Member

hynek commented Jul 20, 2020

I guess a fairer name would be AttributeDefinition but I wonder if we couldn't spin it in a way that the hook receives Attributes but is free to replace them with something else? The would be definitely cleaner and less invasive.

@sscherfke
Copy link
Contributor Author

I’m not sure if I understand what you mean. The whole purpose of the hook is to be invasive and let the user mess with the attribute definition.

@hynek
Copy link
Member

hynek commented Jul 20, 2020

I mean that due to stuff like resolving decorator-based defaults and validators we can’t really provide a good interface? My hope would be that the hook would get a list of Attributes will fully resolved validators etc and would return a list of Attributes that may replace some of them or even remove some?

@sscherfke
Copy link
Contributor Author

Thanks for the clarification. I will think about this and see if it works.

@hynek
Copy link
Member

hynek commented Jul 21, 2020

Yeah, please let me know what you think. The upsides are mainly that we don’t have to introduce a new “in-between type” that would have to be mutated by the users. That smells like bugs and edge cases to me. I’m open to add more helper APIs to Attribute, though!

@sscherfke
Copy link
Contributor Author

This was an excelent idea of you, @hynek. :) The hook is now purely functional. It takes an Attribute and returns an Attribute. The only thing that we’d need to change now is to make Attribute._assoc public in order to allow people to evolve an attribute.

@sscherfke sscherfke requested a review from hynek September 6, 2020 15:27
@hynek hynek added this to the 20.3.0 milestone Sep 14, 2020
@sscherfke
Copy link
Contributor Author

ping 🐈

@hynek
Copy link
Member

hynek commented Sep 25, 2020

ping 🐈

Current status:

current status

😇

@sscherfke
Copy link
Contributor Author

Oh, I thought you’re already back. Then have a lot of fun and I’ll be patient! 🏄

Copy link
Member

@hynek hynek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A lot of nitpicking but thanks to the magic of suggestions, it should be quick to get thru!

collapses on the floor

changelog.d/653.change.rst Outdated Show resolved Hide resolved
changelog.d/653.change.rst Outdated Show resolved Hide resolved
docs/extending.rst Outdated Show resolved Hide resolved
docs/extending.rst Outdated Show resolved Hide resolved
docs/extending.rst Outdated Show resolved Hide resolved
tests/test_hooks.py Outdated Show resolved Hide resolved
tests/test_hooks.py Outdated Show resolved Hide resolved
tests/test_hooks.py Outdated Show resolved Hide resolved
tests/test_hooks.py Outdated Show resolved Hide resolved
tests/test_hooks.py Outdated Show resolved Hide resolved
@sscherfke sscherfke force-pushed the master branch 4 times, most recently from 77e2d2e to f8dc178 Compare October 6, 2020 18:11
@sscherfke sscherfke requested a review from hynek October 6, 2020 18:12
@sscherfke
Copy link
Contributor Author

Ohai, this is the weekly ping. 🙊

@hynek hynek changed the title WIP: Improve (de)serialization and validation capabilities Improve (de)serialization and validation capabilities Oct 15, 2020
Copy link
Member

@hynek hynek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should change _assoc to evolve, not assoc but I’ll do it myself, to not delay this any further. Thanks and thank you for the patience, this is a big one!

@hynek hynek merged commit 0eae613 into python-attrs:master Oct 15, 2020
@sscherfke
Copy link
Contributor Author

Thanks for merging! ❤️

Next PR will arrive shortly 😬

aio-libs-github-bot bot pushed a commit to aio-libs/aiohttp that referenced this pull request Nov 6, 2020
Bumps [attrs](https://github.com/python-attrs/attrs) from 20.2.0 to 20.3.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/python-attrs/attrs/releases">attrs's releases</a>.</em></p>
<blockquote>
<h2>20.3.0</h2>
<h2>Backward-incompatible Changes</h2>
<ul>
<li>
<p><code>attr.define()</code>, <code>attr.frozen()</code>, <code>attr.mutable()</code>, and <code>attr.field()</code> remain <strong>provisional</strong>.</p>
<p>This release does <strong>not</strong> change change anything about them and they are already used widely in production though.</p>
<p>If you wish to use them together with mypy, you can simply drop <a href="https://gist.github.com/hynek/1e3844d0c99e479e716169034b5fa963#file-attrs_ng_plugin-py">this plugin</a> into your project.</p>
<p>Feel free to provide feedback to them in the linked issue <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/668">#668</a>.</p>
<p>We will release the <code>attrs</code> namespace once we have the feeling that the APIs have properly settled. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/668">#668</a></p>
</li>
</ul>
<h2>Changes</h2>
<ul>
<li><code>attr.s()</code> now has a <em>field_transformer</em> hook that is called for all <code>Attribute</code>s and returns a (modified or updated) list of <code>Attribute</code> instances. <code>attr.asdict()</code> has a <em>value_serializer</em> hook that can change the way values are converted. Both hooks are meant to help with data (de-)serialization workflows. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/653">#653</a></li>
<li><code>kw_only=True</code> now works on Python 2. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/700">#700</a></li>
<li><code>raise from</code> now works on frozen classes on PyPy. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/703">#703</a>, <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/712">#712</a></li>
<li><code>attr.asdict()</code> and <code>attr.astuple()</code> now treat <code>frozenset</code>s like <code>set</code>s with regards to the <em>retain_collection_types</em> argument. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/704">#704</a></li>
<li>The type stubs for <code>attr.s()</code> and <code>attr.make_class()</code> are not missing the <em>collect_by_mro</em> argument anymore. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/711">#711</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/python-attrs/attrs/blob/master/CHANGELOG.rst">attrs's changelog</a>.</em></p>
<blockquote>
<h2>20.3.0 (2020-11-05)</h2>
<p>Backward-incompatible Changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p>
<ul>
<li>
<p><code>attr.define()</code>, <code>attr.frozen()</code>, <code>attr.mutable()</code>, and <code>attr.field()</code> remain <strong>provisional</strong>.</p>
<p>This release does <strong>not</strong> change change anything about them and they are already used widely in production though.</p>
<p>If you wish to use them together with mypy, you can simply drop <code>this plugin &lt;https://gist.github.com/hynek/1e3844d0c99e479e716169034b5fa963#file-attrs_ng_plugin-py&gt;</code>_ into your project.</p>
<p>Feel free to provide feedback to them in the linked issue <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/668">#668</a>.</p>
<p>We will release the <code>attrs</code> namespace once we have the feeling that the APIs have properly settled.
<code>[#668](python-attrs/attrs#668) &lt;https://github.com/python-attrs/attrs/issues/668&gt;</code>_</p>
</li>
</ul>
<p>Changes
^^^^^^^</p>
<ul>
<li><code>attr.s()</code> now has a <em>field_transformer</em> hook that is called for all <code>Attribute</code>\ s and returns a (modified or updated) list of <code>Attribute</code> instances.
<code>attr.asdict()</code> has a <em>value_serializer</em> hook that can change the way values are converted.
Both hooks are meant to help with data (de-)serialization workflows.
<code>[#653](python-attrs/attrs#653) &lt;https://github.com/python-attrs/attrs/issues/653&gt;</code>_</li>
<li><code>kw_only=True</code> now works on Python 2.
<code>[#700](python-attrs/attrs#700) &lt;https://github.com/python-attrs/attrs/issues/700&gt;</code>_</li>
<li><code>raise from</code> now works on frozen classes on PyPy.
<code>[#703](python-attrs/attrs#703) &lt;https://github.com/python-attrs/attrs/issues/703&gt;</code><em>,
<code>[#712](python-attrs/attrs#712) &lt;https://github.com/python-attrs/attrs/issues/712&gt;</code></em></li>
<li><code>attr.asdict()</code> and <code>attr.astuple()</code> now treat <code>frozenset</code>\ s like <code>set</code>\ s with regards to the <em>retain_collection_types</em> argument.
<code>[#704](python-attrs/attrs#704) &lt;https://github.com/python-attrs/attrs/issues/704&gt;</code>_</li>
<li>The type stubs for <code>attr.s()</code> and <code>attr.make_class()</code> are not missing the <em>collect_by_mro</em> argument anymore.
<code>[#711](python-attrs/attrs#711) &lt;https://github.com/python-attrs/attrs/issues/711&gt;</code>_</li>
</ul>
<hr />
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/python-attrs/attrs/commit/f3762ba07bf0cec8bebdaaeca2212ba1d662ff13"><code>f3762ba</code></a> Prepare 20.3.0</li>
<li><a href="https://github.com/python-attrs/attrs/commit/3d66e5727b93d3463feb0fd780ae739192e7c363"><code>3d66e57</code></a> Exclude GitHub issues from linkcheck to avoid rate limits</li>
<li><a href="https://github.com/python-attrs/attrs/commit/06d0f8eda63b3f08cb5d94fff9fddf4fe6695621"><code>06d0f8e</code></a> Add funding URLs to metadata</li>
<li><a href="https://github.com/python-attrs/attrs/commit/d23924f765d09f77e87a5c51c1685df0d721b469"><code>d23924f</code></a> Add provisional notice</li>
<li><a href="https://github.com/python-attrs/attrs/commit/cd2f886d6372dca288abf9d999b3e35dacd9ced6"><code>cd2f886</code></a> Use 'i' and 'k' to better distinguish variables in an example (<a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/713">#713</a>)</li>
<li><a href="https://github.com/python-attrs/attrs/commit/f2dabeae82c75abe174aafc7a726481ded929872"><code>f2dabea</code></a> Fix exception chaining on PyPy (<a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/712">#712</a>)</li>
<li><a href="https://github.com/python-attrs/attrs/commit/6b4a1f1ce65162afe54e7101b263859bf8b2177e"><code>6b4a1f1</code></a> Tighten up mypy configuration</li>
<li><a href="https://github.com/python-attrs/attrs/commit/9f7d11e415bc789c9cbab255cb9a5b8903c1b122"><code>9f7d11e</code></a> Add types to collect_by_mro annotations m(</li>
<li><a href="https://github.com/python-attrs/attrs/commit/7020c8b5b55adefc76cf369fb071b1a4b15554a9"><code>7020c8b</code></a> pre-commit autoupdate</li>
<li><a href="https://github.com/python-attrs/attrs/commit/56c73081c5d767e30f529ac4f15a6bdd43e23d9f"><code>56c7308</code></a> Add missing collect_by_mro to typing stubs</li>
<li>Additional commits viewable in <a href="https://github.com/python-attrs/attrs/compare/20.2.0...20.3.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=attrs&package-manager=pip&previous-version=20.2.0&new-version=20.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/configuring-github-dependabot-security-updates)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
commonism pushed a commit to commonism/aiohttp that referenced this pull request Apr 27, 2021
Bumps [attrs](https://github.com/python-attrs/attrs) from 20.2.0 to 20.3.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/python-attrs/attrs/releases">attrs's releases</a>.</em></p>
<blockquote>
<h2>20.3.0</h2>
<h2>Backward-incompatible Changes</h2>
<ul>
<li>
<p><code>attr.define()</code>, <code>attr.frozen()</code>, <code>attr.mutable()</code>, and <code>attr.field()</code> remain <strong>provisional</strong>.</p>
<p>This release does <strong>not</strong> change change anything about them and they are already used widely in production though.</p>
<p>If you wish to use them together with mypy, you can simply drop <a href="https://gist.github.com/hynek/1e3844d0c99e479e716169034b5fa963#file-attrs_ng_plugin-py">this plugin</a> into your project.</p>
<p>Feel free to provide feedback to them in the linked issue <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/668">#668</a>.</p>
<p>We will release the <code>attrs</code> namespace once we have the feeling that the APIs have properly settled. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/668">#668</a></p>
</li>
</ul>
<h2>Changes</h2>
<ul>
<li><code>attr.s()</code> now has a <em>field_transformer</em> hook that is called for all <code>Attribute</code>s and returns a (modified or updated) list of <code>Attribute</code> instances. <code>attr.asdict()</code> has a <em>value_serializer</em> hook that can change the way values are converted. Both hooks are meant to help with data (de-)serialization workflows. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/653">#653</a></li>
<li><code>kw_only=True</code> now works on Python 2. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/700">#700</a></li>
<li><code>raise from</code> now works on frozen classes on PyPy. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/703">#703</a>, <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/712">#712</a></li>
<li><code>attr.asdict()</code> and <code>attr.astuple()</code> now treat <code>frozenset</code>s like <code>set</code>s with regards to the <em>retain_collection_types</em> argument. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/704">#704</a></li>
<li>The type stubs for <code>attr.s()</code> and <code>attr.make_class()</code> are not missing the <em>collect_by_mro</em> argument anymore. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/711">#711</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/python-attrs/attrs/blob/master/CHANGELOG.rst">attrs's changelog</a>.</em></p>
<blockquote>
<h2>20.3.0 (2020-11-05)</h2>
<p>Backward-incompatible Changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p>
<ul>
<li>
<p><code>attr.define()</code>, <code>attr.frozen()</code>, <code>attr.mutable()</code>, and <code>attr.field()</code> remain <strong>provisional</strong>.</p>
<p>This release does <strong>not</strong> change change anything about them and they are already used widely in production though.</p>
<p>If you wish to use them together with mypy, you can simply drop <code>this plugin &lt;https://gist.github.com/hynek/1e3844d0c99e479e716169034b5fa963#file-attrs_ng_plugin-py&gt;</code>_ into your project.</p>
<p>Feel free to provide feedback to them in the linked issue <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/668">#668</a>.</p>
<p>We will release the <code>attrs</code> namespace once we have the feeling that the APIs have properly settled.
<code>[aio-libs#668](python-attrs/attrs#668) &lt;https://github.com/python-attrs/attrs/issues/668&gt;</code>_</p>
</li>
</ul>
<p>Changes
^^^^^^^</p>
<ul>
<li><code>attr.s()</code> now has a <em>field_transformer</em> hook that is called for all <code>Attribute</code>\ s and returns a (modified or updated) list of <code>Attribute</code> instances.
<code>attr.asdict()</code> has a <em>value_serializer</em> hook that can change the way values are converted.
Both hooks are meant to help with data (de-)serialization workflows.
<code>[aio-libs#653](python-attrs/attrs#653) &lt;https://github.com/python-attrs/attrs/issues/653&gt;</code>_</li>
<li><code>kw_only=True</code> now works on Python 2.
<code>[aio-libs#700](python-attrs/attrs#700) &lt;https://github.com/python-attrs/attrs/issues/700&gt;</code>_</li>
<li><code>raise from</code> now works on frozen classes on PyPy.
<code>[aio-libs#703](python-attrs/attrs#703) &lt;https://github.com/python-attrs/attrs/issues/703&gt;</code><em>,
<code>[aio-libs#712](python-attrs/attrs#712) &lt;https://github.com/python-attrs/attrs/issues/712&gt;</code></em></li>
<li><code>attr.asdict()</code> and <code>attr.astuple()</code> now treat <code>frozenset</code>\ s like <code>set</code>\ s with regards to the <em>retain_collection_types</em> argument.
<code>[aio-libs#704](python-attrs/attrs#704) &lt;https://github.com/python-attrs/attrs/issues/704&gt;</code>_</li>
<li>The type stubs for <code>attr.s()</code> and <code>attr.make_class()</code> are not missing the <em>collect_by_mro</em> argument anymore.
<code>[aio-libs#711](python-attrs/attrs#711) &lt;https://github.com/python-attrs/attrs/issues/711&gt;</code>_</li>
</ul>
<hr />
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/python-attrs/attrs/commit/f3762ba07bf0cec8bebdaaeca2212ba1d662ff13"><code>f3762ba</code></a> Prepare 20.3.0</li>
<li><a href="https://github.com/python-attrs/attrs/commit/3d66e5727b93d3463feb0fd780ae739192e7c363"><code>3d66e57</code></a> Exclude GitHub issues from linkcheck to avoid rate limits</li>
<li><a href="https://github.com/python-attrs/attrs/commit/06d0f8eda63b3f08cb5d94fff9fddf4fe6695621"><code>06d0f8e</code></a> Add funding URLs to metadata</li>
<li><a href="https://github.com/python-attrs/attrs/commit/d23924f765d09f77e87a5c51c1685df0d721b469"><code>d23924f</code></a> Add provisional notice</li>
<li><a href="https://github.com/python-attrs/attrs/commit/cd2f886d6372dca288abf9d999b3e35dacd9ced6"><code>cd2f886</code></a> Use 'i' and 'k' to better distinguish variables in an example (<a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/713">#713</a>)</li>
<li><a href="https://github.com/python-attrs/attrs/commit/f2dabeae82c75abe174aafc7a726481ded929872"><code>f2dabea</code></a> Fix exception chaining on PyPy (<a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/712">#712</a>)</li>
<li><a href="https://github.com/python-attrs/attrs/commit/6b4a1f1ce65162afe54e7101b263859bf8b2177e"><code>6b4a1f1</code></a> Tighten up mypy configuration</li>
<li><a href="https://github.com/python-attrs/attrs/commit/9f7d11e415bc789c9cbab255cb9a5b8903c1b122"><code>9f7d11e</code></a> Add types to collect_by_mro annotations m(</li>
<li><a href="https://github.com/python-attrs/attrs/commit/7020c8b5b55adefc76cf369fb071b1a4b15554a9"><code>7020c8b</code></a> pre-commit autoupdate</li>
<li><a href="https://github.com/python-attrs/attrs/commit/56c73081c5d767e30f529ac4f15a6bdd43e23d9f"><code>56c7308</code></a> Add missing collect_by_mro to typing stubs</li>
<li>Additional commits viewable in <a href="https://github.com/python-attrs/attrs/compare/20.2.0...20.3.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=attrs&package-manager=pip&previous-version=20.2.0&new-version=20.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/configuring-github-dependabot-security-updates)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
commonism pushed a commit to commonism/aiohttp that referenced this pull request Apr 27, 2021
Bumps [attrs](https://github.com/python-attrs/attrs) from 20.2.0 to 20.3.0.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/python-attrs/attrs/releases">attrs's releases</a>.</em></p>
<blockquote>
<h2>20.3.0</h2>
<h2>Backward-incompatible Changes</h2>
<ul>
<li>
<p><code>attr.define()</code>, <code>attr.frozen()</code>, <code>attr.mutable()</code>, and <code>attr.field()</code> remain <strong>provisional</strong>.</p>
<p>This release does <strong>not</strong> change change anything about them and they are already used widely in production though.</p>
<p>If you wish to use them together with mypy, you can simply drop <a href="https://gist.github.com/hynek/1e3844d0c99e479e716169034b5fa963#file-attrs_ng_plugin-py">this plugin</a> into your project.</p>
<p>Feel free to provide feedback to them in the linked issue <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/668">#668</a>.</p>
<p>We will release the <code>attrs</code> namespace once we have the feeling that the APIs have properly settled. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/668">#668</a></p>
</li>
</ul>
<h2>Changes</h2>
<ul>
<li><code>attr.s()</code> now has a <em>field_transformer</em> hook that is called for all <code>Attribute</code>s and returns a (modified or updated) list of <code>Attribute</code> instances. <code>attr.asdict()</code> has a <em>value_serializer</em> hook that can change the way values are converted. Both hooks are meant to help with data (de-)serialization workflows. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/653">#653</a></li>
<li><code>kw_only=True</code> now works on Python 2. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/700">#700</a></li>
<li><code>raise from</code> now works on frozen classes on PyPy. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/703">#703</a>, <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/712">#712</a></li>
<li><code>attr.asdict()</code> and <code>attr.astuple()</code> now treat <code>frozenset</code>s like <code>set</code>s with regards to the <em>retain_collection_types</em> argument. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/704">#704</a></li>
<li>The type stubs for <code>attr.s()</code> and <code>attr.make_class()</code> are not missing the <em>collect_by_mro</em> argument anymore. <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/711">#711</a></li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/python-attrs/attrs/blob/master/CHANGELOG.rst">attrs's changelog</a>.</em></p>
<blockquote>
<h2>20.3.0 (2020-11-05)</h2>
<p>Backward-incompatible Changes
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</p>
<ul>
<li>
<p><code>attr.define()</code>, <code>attr.frozen()</code>, <code>attr.mutable()</code>, and <code>attr.field()</code> remain <strong>provisional</strong>.</p>
<p>This release does <strong>not</strong> change change anything about them and they are already used widely in production though.</p>
<p>If you wish to use them together with mypy, you can simply drop <code>this plugin &lt;https://gist.github.com/hynek/1e3844d0c99e479e716169034b5fa963#file-attrs_ng_plugin-py&gt;</code>_ into your project.</p>
<p>Feel free to provide feedback to them in the linked issue <a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/668">#668</a>.</p>
<p>We will release the <code>attrs</code> namespace once we have the feeling that the APIs have properly settled.
<code>[aio-libs#668](python-attrs/attrs#668) &lt;https://github.com/python-attrs/attrs/issues/668&gt;</code>_</p>
</li>
</ul>
<p>Changes
^^^^^^^</p>
<ul>
<li><code>attr.s()</code> now has a <em>field_transformer</em> hook that is called for all <code>Attribute</code>\ s and returns a (modified or updated) list of <code>Attribute</code> instances.
<code>attr.asdict()</code> has a <em>value_serializer</em> hook that can change the way values are converted.
Both hooks are meant to help with data (de-)serialization workflows.
<code>[aio-libs#653](python-attrs/attrs#653) &lt;https://github.com/python-attrs/attrs/issues/653&gt;</code>_</li>
<li><code>kw_only=True</code> now works on Python 2.
<code>[aio-libs#700](python-attrs/attrs#700) &lt;https://github.com/python-attrs/attrs/issues/700&gt;</code>_</li>
<li><code>raise from</code> now works on frozen classes on PyPy.
<code>[aio-libs#703](python-attrs/attrs#703) &lt;https://github.com/python-attrs/attrs/issues/703&gt;</code><em>,
<code>[aio-libs#712](python-attrs/attrs#712) &lt;https://github.com/python-attrs/attrs/issues/712&gt;</code></em></li>
<li><code>attr.asdict()</code> and <code>attr.astuple()</code> now treat <code>frozenset</code>\ s like <code>set</code>\ s with regards to the <em>retain_collection_types</em> argument.
<code>[aio-libs#704](python-attrs/attrs#704) &lt;https://github.com/python-attrs/attrs/issues/704&gt;</code>_</li>
<li>The type stubs for <code>attr.s()</code> and <code>attr.make_class()</code> are not missing the <em>collect_by_mro</em> argument anymore.
<code>[aio-libs#711](python-attrs/attrs#711) &lt;https://github.com/python-attrs/attrs/issues/711&gt;</code>_</li>
</ul>
<hr />
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/python-attrs/attrs/commit/f3762ba07bf0cec8bebdaaeca2212ba1d662ff13"><code>f3762ba</code></a> Prepare 20.3.0</li>
<li><a href="https://github.com/python-attrs/attrs/commit/3d66e5727b93d3463feb0fd780ae739192e7c363"><code>3d66e57</code></a> Exclude GitHub issues from linkcheck to avoid rate limits</li>
<li><a href="https://github.com/python-attrs/attrs/commit/06d0f8eda63b3f08cb5d94fff9fddf4fe6695621"><code>06d0f8e</code></a> Add funding URLs to metadata</li>
<li><a href="https://github.com/python-attrs/attrs/commit/d23924f765d09f77e87a5c51c1685df0d721b469"><code>d23924f</code></a> Add provisional notice</li>
<li><a href="https://github.com/python-attrs/attrs/commit/cd2f886d6372dca288abf9d999b3e35dacd9ced6"><code>cd2f886</code></a> Use 'i' and 'k' to better distinguish variables in an example (<a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/713">#713</a>)</li>
<li><a href="https://github.com/python-attrs/attrs/commit/f2dabeae82c75abe174aafc7a726481ded929872"><code>f2dabea</code></a> Fix exception chaining on PyPy (<a href="https://github-redirect.dependabot.com/python-attrs/attrs/issues/712">#712</a>)</li>
<li><a href="https://github.com/python-attrs/attrs/commit/6b4a1f1ce65162afe54e7101b263859bf8b2177e"><code>6b4a1f1</code></a> Tighten up mypy configuration</li>
<li><a href="https://github.com/python-attrs/attrs/commit/9f7d11e415bc789c9cbab255cb9a5b8903c1b122"><code>9f7d11e</code></a> Add types to collect_by_mro annotations m(</li>
<li><a href="https://github.com/python-attrs/attrs/commit/7020c8b5b55adefc76cf369fb071b1a4b15554a9"><code>7020c8b</code></a> pre-commit autoupdate</li>
<li><a href="https://github.com/python-attrs/attrs/commit/56c73081c5d767e30f529ac4f15a6bdd43e23d9f"><code>56c7308</code></a> Add missing collect_by_mro to typing stubs</li>
<li>Additional commits viewable in <a href="https://github.com/python-attrs/attrs/compare/20.2.0...20.3.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=attrs&package-manager=pip&previous-version=20.2.0&new-version=20.3.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/configuring-github-dependabot-security-updates)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
chrisjsewell added a commit to executablebooks/sphinx-external-toc that referenced this pull request Jul 16, 2021
`value_serializer` has been supported since this version
(see: python-attrs/attrs#653)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants