Skip to content

style+test: modernize Python type stubs & expand test coverage#136

Merged
deedy5 merged 2 commits intomainfrom
dev
Apr 2, 2026
Merged

style+test: modernize Python type stubs & expand test coverage#136
deedy5 merged 2 commits intomainfrom
dev

Conversation

@deedy5
Copy link
Copy Markdown
Owner

@deedy5 deedy5 commented Apr 2, 2026

Summary

  • Modernize primp.pyi type annotations (Optional → X | None, Dict → dict, Tuple → tuple, Union → X | Y), fix ruff/mypy lint errors, and reformat all Python files
  • Add 65 new tests (261 → 326) covering StreamResponse properties, Client/AsyncClient getters/setters, request body variants, and async error handling
  • Fix intermittent CI crash in test server by catching BrokenPipeError/ConnectionResetError on wfile.write during interpreter shutdown

deedy5 added 2 commits April 2, 2026 22:49
Fix intermittent CI crash in test server by wrapping wfile.write calls
with try/except to handle BrokenPipeError/ConnectionResetError/OSError
during Python interpreter shutdown with daemon threads.

Suppress ConnectionResetError in test server handler.

Add 65 new tests (261 -> 326) covering previously untested API surface:

- StreamResponse/AsyncStreamResponse properties (url, status_code, headers,
  cookies, encoding, content, text, raise_for_status)
- StreamResponse.next() and AsyncStreamResponse.anext() methods
- iter_bytes(chunk_size) and iter_text(chunk_size) parameters
- Client/AsyncClient impersonate and impersonate_os getters with values
- AsyncClient constructor params (cookie_store, referer, ca_cert_file,
  proxy, verify, https_only, http2_only)
- Client/AsyncClient property setters (auth, auth_bearer, params, timeout)
- request() method with JSON/content/form_data body variants
- Response.encoding setter (sync and async)
- StatusError args containing status code
- Module-level verify parameter
- Async raise_for_status for 500 status
- Fix deprecated typing imports (Optional[X] -> X | None, Dict -> dict, Tuple -> tuple, Union -> X | Y)
- Remove unused typing imports (Iterator, AsyncIterator, Optional)
- Fix import sorting in examples and stub file
- Remove f-string without placeholders in benchmark/run.py
- Fix useless attribute access (B018) in benchmark/benchmark.py
- Fix long lines (E501) in benchmark/benchmark.py
- Reformat all files with ruff format
@deedy5 deedy5 merged commit b856eee into main Apr 2, 2026
19 checks passed
@deedy5 deedy5 deleted the dev branch April 2, 2026 20:09
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