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

Enhance type of headers.get method. #2129

Merged
merged 1 commit into from May 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Expand Up @@ -14,6 +14,7 @@ Unreleased
decorated with it report the correct type. :issue:`2113`
- Fix multipart parsing bug when boundary contains special regex
characters. :issue:`2125`
- Enhance type annotation for ``headers.get``. :issue:`2128`


Version 2.0.0
Expand Down
2 changes: 2 additions & 0 deletions src/werkzeug/datastructures.pyi
Expand Up @@ -220,6 +220,8 @@ class Headers(Dict[str, str]):
def __getitem__(self, key: str, _get_mode: Literal[True] = ...) -> str: ...
def __eq__(self, other: object) -> bool: ...
@overload # type: ignore
def get(self, key: str, default: str) -> str: ...
@overload
def get(self, key: str, default: Optional[str] = None) -> Optional[str]: ...
@overload
def get(
Expand Down
2 changes: 1 addition & 1 deletion src/werkzeug/sansio/request.py
Expand Up @@ -491,7 +491,7 @@ def user_agent(self) -> UserAgent:
Werkzeug 2.1. A ``UserAgent`` subclass must be set to parse
data from the string.
"""
return self.user_agent_class(t.cast(str, self.headers.get("User-Agent", "")))
return self.user_agent_class(self.headers.get("User-Agent", ""))

# Authorization

Expand Down