Skip to content

Add Client Middleware Cookbook #10945

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

Merged
merged 18 commits into from
May 23, 2025
Merged

Add Client Middleware Cookbook #10945

merged 18 commits into from
May 23, 2025

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented May 22, 2025

Adds client middleware cookbook and examples

This is still quite raw, but I am opening it so the team can adjust/add
@bdraco bdraco added this to the 3.12 milestone May 22, 2025
@bdraco bdraco added the backport-3.12 Trigger automatic backporting to the 3.12 release branch by Patchback robot label May 22, 2025
Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.76%. Comparing base (06e3b36) to head (d6e01a7).
Report is 7 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #10945      +/-   ##
==========================================
- Coverage   98.77%   98.76%   -0.01%     
==========================================
  Files         129      129              
  Lines       39539    39541       +2     
  Branches     2186     2185       -1     
==========================================
  Hits        39054    39054              
- Misses        337      339       +2     
  Partials      148      148              
Flag Coverage Δ
CI-GHA 98.64% <ø> (-0.01%) ⬇️
OS-Linux 98.35% <ø> (-0.01%) ⬇️
OS-Windows 96.53% <ø> (-0.01%) ⬇️
OS-macOS 97.51% <ø> (+<0.01%) ⬆️
Py-3.10.11 97.40% <ø> (-0.01%) ⬇️
Py-3.10.17 97.93% <ø> (-0.01%) ⬇️
Py-3.11.12 98.02% <ø> (-0.01%) ⬇️
Py-3.11.9 97.48% <ø> (-0.01%) ⬇️
Py-3.12.10 98.41% <ø> (-0.01%) ⬇️
Py-3.13.3 98.41% <ø> (+<0.01%) ⬆️
Py-3.9.13 97.27% <ø> (-0.01%) ⬇️
Py-3.9.22 97.76% <ø> (-0.05%) ⬇️
Py-pypy7.3.16 93.50% <ø> (+8.52%) ⬆️
VM-macos 97.51% <ø> (+<0.01%) ⬆️
VM-ubuntu 98.35% <ø> (-0.01%) ⬇️
VM-windows 96.53% <ø> (-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.

Copy link

codspeed-hq bot commented May 22, 2025

CodSpeed Performance Report

Merging #10945 will not alter performance

Comparing client_middleware_cookbook (d6e01a7) with master (5e68276)

Summary

✅ 59 untouched benchmarks

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label May 22, 2025
@bdraco bdraco requested a review from Copilot May 22, 2025 22:49
@bdraco bdraco marked this pull request as ready for review May 22, 2025 22:49
@bdraco bdraco requested a review from asvetlov as a code owner May 22, 2025 22:49
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new Client Middleware Cookbook with practical examples, integrates it into the main client docs, updates the spelling wordlist, and adds a CHANGES entry.

  • Introduce a comprehensive client_middleware_cookbook.rst with multiple middleware patterns.
  • Link the new cookbook in docs/client.rst and add “backoff” to the spelling wordlist.
  • Add a CHANGES file placeholder entry for this feature.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
docs/spelling_wordlist.txt Added “backoff” to the approved spelling list.
docs/client_middleware_cookbook.rst New cookbook covering Basic Auth, retry, logging, and token refresh middleware.
docs/client.rst Inserted navigation link to the Client Middleware Cookbook.
CHANGES/10945.feature.rst Created feature entry (filename and content need alignment).
Comments suppressed due to low confidence (2)

docs/client_middleware_cookbook.rst:305

  • ClientRequest does not have a session attribute; request.session will likely be undefined. Consider passing the ClientSession instance into the middleware (e.g., store it on init) or otherwise provide access to the session for token refresh calls.
await self._refresh_access_token(request.session)

CHANGES/10945.feature.rst:1

  • The change entry references 9732.feature.rst but the filename is 10945.feature.rst. Update the internal reference to match the correct feature number.
9732.feature.rst

@bdraco bdraco enabled auto-merge (squash) May 23, 2025 15:09
@bdraco bdraco added the documentation Improvements or additions to documentation label May 23, 2025
@bdraco bdraco merged commit 1878509 into master May 23, 2025
41 checks passed
@bdraco bdraco deleted the client_middleware_cookbook branch May 23, 2025 15:20
Copy link
Contributor

patchback bot commented May 23, 2025

Backport to 3.12: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.12/18785096b3628f682f950c612d8acb68333629ba/pr-10945

Backported as #10969

🤖 @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 May 23, 2025
bdraco added a commit that referenced this pull request May 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants