Compare commits
1 Commits
main
...
remove-get
Author | SHA1 | Date | |
---|---|---|---|
|
b692309c91 |
|
@ -149,13 +149,11 @@ class CookieRequestParameters(RequestParameters):
|
|||
except KeyError:
|
||||
return super().get(name, default)
|
||||
|
||||
def getlist(
|
||||
self, name: str, default: Optional[Any] = None
|
||||
) -> Optional[Any]:
|
||||
def getlist(self, name: str) -> list[Any]:
|
||||
try:
|
||||
return self._get_prefixed_cookie(name)
|
||||
except KeyError:
|
||||
return super().getlist(name, default)
|
||||
return super().getlist(name)
|
||||
|
||||
def _get_prefixed_cookie(self, name: str) -> Any:
|
||||
getitem = super().__getitem__
|
||||
|
|
|
@ -19,15 +19,14 @@ class RequestParameters(dict):
|
|||
return super().get(name, [default])[0]
|
||||
|
||||
def getlist(
|
||||
self, name: str, default: Optional[Any] = None
|
||||
) -> Optional[Any]:
|
||||
self, name: str
|
||||
) -> list[Any]:
|
||||
"""Return the entire list
|
||||
|
||||
Args:
|
||||
name (str): The name of the parameter
|
||||
default (Optional[Any], optional): The default value. Defaults to None.
|
||||
|
||||
Returns:
|
||||
Optional[Any]: The entire list
|
||||
list[Any]: The entire list of values or [] if not found
|
||||
""" # noqa: E501
|
||||
return super().get(name, default)
|
||||
return super().get(name) or []
|
||||
|
|
|
@ -445,10 +445,10 @@ def test_cookie_accessors(app: Sanic):
|
|||
"four": request.cookies.get("four", "fallback"),
|
||||
},
|
||||
"getlist": {
|
||||
"one": request.cookies.getlist("one", ["fallback"]),
|
||||
"two": request.cookies.getlist("two", ["fallback"]),
|
||||
"three": request.cookies.getlist("three", ["fallback"]),
|
||||
"four": request.cookies.getlist("four", ["fallback"]),
|
||||
"one": request.cookies.getlist("one"),
|
||||
"two": request.cookies.getlist("two"),
|
||||
"three": request.cookies.getlist("three"),
|
||||
"four": request.cookies.getlist("four"),
|
||||
},
|
||||
"getattr": {
|
||||
"one": request.cookies.one,
|
||||
|
@ -484,7 +484,7 @@ def test_cookie_accessors(app: Sanic):
|
|||
"one": ["1"],
|
||||
"two": ["2"],
|
||||
"three": ["3"],
|
||||
"four": ["fallback"],
|
||||
"four": [],
|
||||
},
|
||||
"getattr": {
|
||||
"one": "1",
|
||||
|
|
Loading…
Reference in New Issue
Block a user