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

Add slots to dataclasses with Python 3.10+ #9413

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Oct 3, 2024

I'm 50/50 on if we should move this forward as I'm not sure 4.x will be out by the time we drop python 3.9 support and once we do we can add slots=True to all the dataclasses anyways (if we don't forget)

What do these changes do?

Add slots to dataclasses with Python 3.10+. No need to backport as 3.x uses attrs and already has slots here.

This idea comes from https://github.com/esphome/aioesphomeapi/blob/main/aioesphomeapi/model.py where we have a lot of small data classes generated from protobuf messages but still need to support older python.

related issue #4618 (comment)

Are there changes in behavior for the user?

no

Is it a substantial burden for the maintainers to support this?

no

@bdraco
Copy link
Member Author

bdraco commented Oct 3, 2024

3.x already has slots

aiohttp/client.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/client_reqrep.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/client_reqrep.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/client_reqrep.py:@attr.s(auto_attribs=True, slots=True, frozen=True, cache_hash=True)
aiohttp/client_ws.py:@attr.s(frozen=True, slots=True)
aiohttp/helpers.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/helpers.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/helpers.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/tracing.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/web_protocol.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/web_request.py:@attr.s(auto_attribs=True, frozen=True, slots=True)
aiohttp/web_routedef.py:@attr.s(auto_attribs=True, frozen=True, repr=False, slots=True)
aiohttp/web_routedef.py:@attr.s(auto_attribs=True, frozen=True, repr=False, slots=True)
aiohttp/web_ws.py:@attr.s(auto_attribs=True, frozen=True, slots=True)

Copy link

codecov bot commented Oct 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.57%. Comparing base (24b0e6f) to head (b3d666e).

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9413      +/-   ##
==========================================
- Coverage   98.57%   98.57%   -0.01%     
==========================================
  Files         107      107              
  Lines       35048    35046       -2     
  Branches     4150     4151       +1     
==========================================
- Hits        34547    34545       -2     
  Misses        334      334              
  Partials      167      167              
Flag Coverage Δ
CI-GHA 98.44% <97.05%> (-0.01%) ⬇️
OS-Linux 98.11% <97.05%> (-0.01%) ⬇️
OS-Windows 96.52% <96.55%> (-0.01%) ⬇️
OS-macOS 97.80% <97.05%> (-0.01%) ⬇️
Py-3.10.11 97.66% <94.11%> (-0.01%) ⬇️
Py-3.10.15 97.60% <94.11%> (-0.01%) ⬇️
Py-3.11.10 97.67% <94.11%> (-0.01%) ⬇️
Py-3.11.9 97.74% <94.11%> (-0.01%) ⬇️
Py-3.12.6 98.16% <94.11%> (-0.01%) ⬇️
Py-3.13.0-rc.3 98.14% <94.11%> (-0.01%) ⬇️
Py-3.9.13 97.56% <94.11%> (-0.01%) ⬇️
Py-3.9.20 97.50% <94.11%> (-0.01%) ⬇️
Py-pypy7.3.16 97.12% <94.11%> (-0.01%) ⬇️
VM-macos 97.80% <97.05%> (-0.01%) ⬇️
VM-ubuntu 98.11% <97.05%> (-0.01%) ⬇️
VM-windows 96.52% <96.55%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Oct 4, 2024
@bdraco bdraco added the backport:skip Skip backport bot label Oct 4, 2024
@bdraco bdraco marked this pull request as ready for review October 4, 2024 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip Skip backport bot bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant