Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CacheControl issues #2882

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

RazerM
Copy link

@RazerM RazerM commented Apr 19, 2024

  • no-transform is a boolean, rather than always None.
  • min-fresh is an int, returning None if empty rather than *.
  • Fix some property types:
    • Bool properties never return None.
    • Non-bool types return str not bool.
    • max-stale can return "*"
    • Request properties are immutable
    • Fix some response setter types
  • Add must-understand response property.

Fixes #2881

no-transform has no arguments as a request or response directive (RFC
9111). Prior to this fix, cc.no_transform would return None whether the
directive is present or not.
The type for this property is `int | None`, so getting `"*"` for a
malformed directive is surprising. I think dropping the empty value here
is better than fixing the type.
- cache_control_property with type=bool never return None
- some non-bool types were marked as returning bool instead of str
- max_stale can return "*" in addition to int or None
mypy doesn't use the type of setters as of 1.9.0 (see python/mypy#3004),
but I think it's still good to have these be accurate (maybe the other
type checkers work better here).

mypy's recommendation is to use `# type: ignore` comments if setter
types don't match getters, which you see when setting no_cache to True.
@RazerM RazerM force-pushed the feature/cache-control-issues branch from 333ad19 to 8bff7d0 Compare April 19, 2024 11:06
@davidism davidism modified the milestones: 3.0.3, 3.1.0 May 4, 2024
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.

Several issues with CacheControl types
2 participants