Skip to content

Commit

Permalink
Merge pull request #2129 from bayesimpact/pascal-type-get
Browse files Browse the repository at this point in the history
Enhance type of `headers.get` method.
  • Loading branch information
davidism committed May 17, 2021
2 parents 1104012 + 625aaba commit 1b8907a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
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

0 comments on commit 1b8907a

Please sign in to comment.