Skip to content

Commit

Permalink
Fix CacheControl setter type stubs
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
RazerM committed Apr 19, 2024
1 parent 8be95fa commit 8bff7d0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/werkzeug/datastructures/cache_control.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class _CacheControl(
@property
def no_cache(self) -> str | None: ...
@no_cache.setter
def no_cache(self, value: bool | None) -> None: ...
def no_cache(self, value: Literal[True] | str | None) -> None: ...
@no_cache.deleter
def no_cache(self) -> None: ...
@property
Expand Down Expand Up @@ -83,7 +83,7 @@ class ResponseCacheControl(_CacheControl):
@property
def private(self) -> str | None: ...
@private.setter
def private(self, value: bool | None) -> None: ...
def private(self, value: Literal[True] | str | None) -> None: ...
@private.deleter
def private(self) -> None: ...
@property
Expand Down
2 changes: 1 addition & 1 deletion src/werkzeug/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def send_file(
elif mtime is not None:
rv.last_modified = mtime # type: ignore

rv.cache_control.no_cache = True
rv.cache_control.no_cache = True # type: ignore

# Flask will pass app.get_send_file_max_age, allowing its send_file
# wrapper to not have to deal with paths.
Expand Down

0 comments on commit 8bff7d0

Please sign in to comment.