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

Make creating RequestInfo backwards compatible with 3.10 #9873

Merged
merged 6 commits into from
Nov 14, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Nov 14, 2024

It was unexpected that this object was being created directly outside of aiohttp internals. While it looks like its only used for mocking internal state downstream, we can accommodate that by subclassing the NamedTuple and providing a __new__ while keeping the faster tuple.__new__ internally.

We might remove the back-compat later in 4.x development cycle, however since its currently being used downstream to mock internals and there isn't a better prescribed way to do that, leave it for now.

fixes #9866

It was unexpected that this object was being created directly
outside of aiohttp internals. While it looks like its only
used for mocking downstream, we can accomodate that by subclassing
the NamedTuple and providing a `__new__` while keeping the faster
`tuple.__new__` internally.

fixes #9866
@bdraco bdraco added the backport-3.11 Trigger automatic backporting to the 3.11 release branch by Patchback robot label Nov 14, 2024
@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Nov 14, 2024
@asvetlov
Copy link
Member

Is it for aioresponses?

Anyway, the perfect example of innocent change that breaks backward compatibility.

I did many such commits in the past, and maybe will do in the future again.

@bdraco
Copy link
Member Author

bdraco commented Nov 14, 2024

Is it for aioresponses?

Anyway, the perfect example of innocent change that breaks backward compatibility.

I did many such commits in the past, and maybe will do in the future again.

Yes. We can also take the position as since they are mocking internals we won't fix it (which was my initial call), but it seems like pnuckowski/aioresponses#262 is moving slow, and realistically they don't have a better way to mock this right now.

Copy link

codspeed-hq bot commented Nov 14, 2024

CodSpeed Performance Report

Merging #9873 will not alter performance

Comparing request_info_back_compat (ac78cb1) with master (4adb061)

Summary

✅ 24 untouched benchmarks

@asvetlov
Copy link
Member

Yes. We can also take the position as since they are mocking internals we won't fix it.

Since restoring the backward compatibility is easy, let's do it.

For more complex case "won't fix" would be an option.
Don't break the code without a reason, don't hesitate to break it if the reason is strong.
My point is: we should do the best in prediction possible breaks and make a careful decision in every particular case.

Copy link

codecov bot commented Nov 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.71%. Comparing base (4adb061) to head (ac78cb1).
Report is 6 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9873   +/-   ##
=======================================
  Coverage   98.71%   98.71%           
=======================================
  Files         118      118           
  Lines       36294    36309   +15     
  Branches     4315     4316    +1     
=======================================
+ Hits        35826    35841   +15     
  Misses        315      315           
  Partials      153      153           
Flag Coverage Δ
CI-GHA 98.60% <100.00%> (+<0.01%) ⬆️
OS-Linux 98.28% <100.00%> (+<0.01%) ⬆️
OS-Windows 96.09% <100.00%> (+<0.01%) ⬆️
OS-macOS 97.37% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 97.21% <100.00%> (-0.01%) ⬇️
Py-3.10.15 97.82% <100.00%> (+0.05%) ⬆️
Py-3.11.10 97.81% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 97.26% <100.00%> (-0.02%) ⬇️
Py-3.12.7 98.35% <100.00%> (+<0.01%) ⬆️
Py-3.13.0 98.29% <100.00%> (-0.06%) ⬇️
Py-3.9.13 97.14% <100.00%> (+<0.01%) ⬆️
Py-3.9.20 97.73% <100.00%> (+0.04%) ⬆️
Py-pypy7.3.16 97.29% <100.00%> (-0.01%) ⬇️
VM-macos 97.37% <100.00%> (+<0.01%) ⬆️
VM-ubuntu 98.28% <100.00%> (+<0.01%) ⬆️
VM-windows 96.09% <100.00%> (+<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.

@asvetlov
Copy link
Member

Third-party that monkey-patches aiohttp is in the danger zone by definition, though.

@bdraco
Copy link
Member Author

bdraco commented Nov 14, 2024

My point is: we should do the best in prediction possible breaks and make a careful decision in every particular case.

Agreed. In this case, I didn't expect someone would be creating these externally... but since its not in a protected namespace, I should have assumed otherwise (and someone always does anyways even if it is)

@bdraco bdraco enabled auto-merge (squash) November 14, 2024 14:37
@asvetlov
Copy link
Member

Yeah, users sometimes use libraries in very unpredictable way :)

@bdraco bdraco merged commit c9698c8 into master Nov 14, 2024
38 of 39 checks passed
@bdraco bdraco deleted the request_info_back_compat branch November 14, 2024 14:39
Copy link
Contributor

patchback bot commented Nov 14, 2024

Backport to 3.11: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.11/c9698c8ecadc344a55e8b05d5c43391e39443ad9/pr-9873

Backported as #9874

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Nov 14, 2024
bdraco pushed a commit that referenced this pull request Nov 14, 2024
…rds compatible with 3.10 (#9874)

Co-authored-by: J. Nick Koston <[email protected]>
fixes #9866
@bdraco bdraco added the backport-3.12 Trigger automatic backporting to the 3.12 release branch by Patchback robot label Nov 14, 2024
Copy link
Contributor

patchback bot commented Nov 14, 2024

Backport to 3.12: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.12/c9698c8ecadc344a55e8b05d5c43391e39443ad9/pr-9873

Backported as #9886

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-3.11 Trigger automatic backporting to the 3.11 release branch by Patchback robot backport-3.12 Trigger automatic backporting to the 3.12 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.

RequestInfo change to a named tuple broke BC
2 participants