Skip to content

Fix RequestsCookieJar iterator type#15890

Open
popsiclelmlm wants to merge 1 commit into
python:mainfrom
popsiclelmlm:codex/requests-cookiejar-iter
Open

Fix RequestsCookieJar iterator type#15890
popsiclelmlm wants to merge 1 commit into
python:mainfrom
popsiclelmlm:codex/requests-cookiejar-iter

Conversation

@popsiclelmlm

Copy link
Copy Markdown

Summary

  • Add an explicit RequestsCookieJar.__iter__ override returning Iterator[Cookie].
  • Add a regression test that asserts iterating over RequestsCookieJar yields Cookie objects.

Reproduction

Root cause

  • The stub models RequestsCookieJar as MutableMapping[str, str] for its mapping-like APIs, but did not explicitly override the conflicting iterator type inherited from CookieJar/runtime behavior.

Changes

  • Declared RequestsCookieJar.__iter__ as Iterator[Cookie].
  • Added stubs/requests/@tests/test_cases/check_cookies.py to cover the iterator type with assert_type.

Tests

  • PATH="$PWD/.venv/bin:$PATH" .venv/bin/python tests/runtests.py stubs/requests
  • git diff --check

Screenshots/Logs

  • Not applicable; type stub/test-only change.

AI disclosure

  • Prepared with assistance from Codex.

Fixes #15457

@github-actions

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

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.

Bad typing for requests.cookies.RequestsCookieJar

1 participant