Preserve existing URL query parameters when params are provided

Draft
FE
3mo ago
+46-10

Summary

  • preserve query parameters already present in a URL when additional params are provided
  • append same-name parameters instead of applying dictionary-style replacement
  • keep copy_with(params=...) and the query manipulation helpers replacement semantics unchanged
  • cover URL, Request, empty parameter inputs, same-name values, explicit queries, and invalid URL types

Closes #1173

Testing

  • uv run --frozen coverage run -m pytest -q — 1998 passed, 1 skipped
  • uv run --frozen coverage report --fail-under=100 — 100%
  • uv run --frozen ruff format --check --diff src/httpx2 tests/httpx2 src/httpcore2 tests/httpcore2 benchmark
  • uv run --frozen ruff check
  • uv run --frozen mypy src/httpx2 tests/httpx2 src/httpcore2 tests/httpcore2 benchmark
  • uv run --frozen python scripts/unasync.py --check

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This does not apply to typos.)
  • I have added a test for each introduced behavior and kept the change atomic.
  • Documentation changes are not required for this bug fix.