Skip to content

Fix AuthHandler lookup and removal examples - #400

Closed
ryanduguid wants to merge 1 commit into
requests:mainfrom
ryanduguid:docs-auth-handler-examples
Closed

ryanduguid wants to merge 1 commit into
requests:mainfrom
ryanduguid:docs-auth-handler-examples

Conversation

@ryanduguid

@ryanduguid ryanduguid commented Oct 8, 2026 •

Copy link
Copy Markdown

Summary

Fix the AuthHandler.get_strategy_for and remove_strategy examples, which pass a set to a constructor that expects a mapping. Include the scheme in each strategy key and use the matching URL when removing it.

AuthHandler({'http://example.com': ('foo', 'bar')})

Evidence

  • Before: Both method examples raise ValueError during construction.
    After: Both corrected examples execute successfully, alongside the existing add_strategy example and an HTTP/HTTPS mismatch control.
  • Windows Python 3.12.10: all five existing AuthHandler tests pass through Tox. Linux documentation builds and package flake8 pass on baseline and candidate; the generated method examples were inspected.
  • Removing docstrings from the parsed Python syntax produces identical baseline and candidate ASTs.
  • Baseline and candidate docstring lint both report exactly the same 171 diagnostics, including positions, with matching Python 3.12.15 and supporting dependencies. Both offline example runs have assertions enabled.

Risk

Only docstring examples change.

Unverified

Full Tox fails: Python 3.9 has the same two X509 deprecation failures on master and on this branch, and Python 3.10 and 3.11 show those failures on this branch (their master runs were not done). Python 2.7, 3.7, 3.8 and PyPy were not run. macOS and upstream CI are unverified.

Construct the example handlers from mappings with full URLs so the
strategy lookup and removal examples execute correctly.
@ryanduguid

Copy link
Copy Markdown
Author

Closing this as part of a tidy-up of my open PRs. Happy to reopen or rebase it if it's still useful.

@ryanduguid ryanduguid closed this Nov 2, 2026
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.

1 participant