Skip to content

Add some typing and fix some tests#3094

Merged
ahopkins merged 5 commits into
mainfrom
tests-cleanup
Nov 30, 2025
Merged

Add some typing and fix some tests#3094
ahopkins merged 5 commits into
mainfrom
tests-cleanup

Conversation

@ahopkins

@ahopkins ahopkins commented Nov 30, 2025

Copy link
Copy Markdown
Member

This pull request introduces several improvements and fixes across the codebase, focusing on type safety, error handling, and test modernization. The most significant changes include stricter type annotations in cookie and worker modules, enhanced error handling for application loading, and updating HTTP/3 receiver tests to use asynchronous functions.

Type Safety and Error Handling Improvements:

  • Updated the initialization of private attributes in sanic/cookies/response.py to use explicit type annotations, improving type safety for expires, max_age, and samesite.
  • Modified the samesite setter in sanic/cookies/response.py to use cast for type correctness when setting the value.
  • Added a check in sanic/worker/loader.py to raise a ValueError if the loaded app is not callable, providing clearer error messages during app loading.
  • Refined type annotations for SSL and config parameters in sanic/worker/serve.py, ensuring better compatibility and clarity with their expected types. [1] [2]

Test Modernization:

  • Converted all test functions in tests/http3/test_http_receiver.py to asynchronous functions (async def), aligning with modern async test practices and ensuring proper handling of async code in tests. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Other minor changes include importing cast from typing for type casting in cookies and updating type hints for os.PathLike usage.

@ahopkins ahopkins requested a review from a team as a code owner November 30, 2025 07:38
@ahopkins ahopkins merged commit 12e1812 into main Nov 30, 2025
27 checks passed
@ahopkins ahopkins deleted the tests-cleanup branch November 30, 2025 08:00
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