[PR #6547/65de218c backport][3.15] Remove overlapping slots and fix broken slots inheritance by aiolibsbot · Pull Request #13716 · aio-libs/aiohttp · GitHub
Skip to content

[PR #6547/65de218c backport][3.15] Remove overlapping slots and fix broken slots inheritance - #13716

Merged
webknjaz merged 4 commits into
aio-libs:3.15from
aiolibsbot:koan/slotscheck-3.15-backport
Sep 15, 2026
Merged

webknjaz merged 4 commits into
aio-libs:3.15from
aiolibsbot:koan/slotscheck-3.15-backport

Conversation

@aiolibsbot

Copy link
Copy Markdown
Contributor

This is a (manual) backport of PR #6547 as merged into master (65de218).

Supersedes #13466: same cherry-pick by @webknjaz, rebased onto current 3.15, plus the fix Lint / sdist needed there.

What do these changes do?

The #6547 backport turns on slotscheck -v -m aiohttp in the sdist lint job. On 3.15 it failed with:

ERROR: 'aiohttp.web_routedef:RouteDef' defines slots but superclass does not.
ERROR: 'aiohttp.web_routedef:StaticDef' defines slots but superclass does not.
       - 'aiohttp.web_routedef:AbstractRouteDef'

Master never hit this because RouteDef and StaticDef are plain dataclasses there. On 3.15 they're still @attr.s(slots=True) classes, but their abc.ABC base has no __slots__, so every instance still got a __dict__. This PR adds __slots__ = () to AbstractRouteDef, which makes the slots work and satisfies slotscheck. It also changes the CI dependency install line to match master's (requirements/base.in -c requirements/base.txt) so the workflow stays the same on both branches.

Are there changes in behavior for the user?

RouteDef and StaticDef instances (from web.get(), web.static(), RouteTableDef, …) no longer have a __dict__. They're frozen attrs classes, so you already couldn't set attributes on them normally. Subclasses of AbstractRouteDef that don't declare __slots__ still get a __dict__.

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

No. It's a one-line change, and slotscheck in CI will stop it from regressing.

Related issue number

Backport of #6547; replaces #13466.

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes — N/A
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt (original author added via the cherry-pick)
  • Add a new news fragment into the CHANGES/ folder
Local verification

slotscheck couldn't be installed offline, so I used a small script that applies the same superclass/overlap rules. On unmodified 3.15 it reported exactly the two CI errors above. With the fix it reported OK (298 classes).

$ pytest tests/test_route_def.py -k slotted      # without the fix
FAILED tests/test_route_def.py::test_route_defs_are_slotted
$ pytest tests/test_route_def.py tests/test_urldispatch.py tests/test_web_urldispatcher.py
224 passed, 1 skipped
$ black --check / flake8 aiohttp/web_routedef.py tests/test_route_def.py   # clean
$ LC_ALL=C sort --check --ignore-case CONTRIBUTORS.txt                   # sorted

Drafted with Claude Opus 5 (Kōan); reviewed by: pending operator review.

ariebovenberg and others added 3 commits September 15, 2026 10:25
)

* Remove overlapping slots, fix broken slots inheritance

* added "CHANGES" entry

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix refs in CHANGES

* added name to contributors

* extra clarification on CookieMixin __slots__ ignore

* add slotscheck to github CI workflow

* use "python -m" in slotscheck run to ensure aiohttp.worker module can be imported

* install base requirements for slotscheck in CI

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
(cherry picked from commit 65de218)
RouteDef and StaticDef are attrs classes with slots=True, but their
slotless abc base still gave every instance a __dict__. slotscheck
rejects this, which failed the Lint job on the aio-libs#6547 backport.
@pyba-chronographer pyba-chronographer Bot added the bot:chronographer:provided There is a change note present in this PR label Sep 15, 2026
@codecov

codecov Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

@codspeed

codspeed Bot commented Sep 15, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 94 untouched benchmarks
⏩ 86 skipped benchmarks1


Comparing aiolibsbot:koan/slotscheck-3.15-backport (919e178) with 3.15 (648e7d9)

Open in CodSpeed

Footnotes

  1. 86 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@webknjaz
webknjaz marked this pull request as ready for review September 15, 2026 11:06
@webknjaz webknjaz added the backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot label Sep 15, 2026
@greptile-apps

greptile-apps Bot commented Sep 15, 2026

Copy link
Copy Markdown

Confidence Score: 4/5

Merge is blocked by an explicit repository requirement for changelog fragment names.

The final review contains one blocking repository-rule finding and no security findings.

Files Needing Attention: CHANGES/6547.bugfix

Reviews (1): Last reviewed commit: "Add change note for AbstractRouteDef slo..." | Re-trigger Greptile

Comment thread CHANGES/6547.bugfix
@webknjaz
webknjaz merged commit 6c0ed6f into aio-libs:3.15 Sep 15, 2026
51 of 52 checks passed
@patchback

patchback Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

webknjaz pushed a commit that referenced this pull request Sep 15, 2026
…] Remove overlapping slots and fix broken slots inheritance (#13726)

Co-authored-by: aio-libs bot <aiolibsbot@koston.org>
Co-authored-by: Arie Bovenberg <a.c.bovenberg@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@aiolibsbot
aiolibsbot deleted the koan/slotscheck-3.15-backport branch September 16, 2026 23:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-3.14 Trigger automatic backporting to the 3.14 release branch by Patchback robot 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.

5 participants