Compare commits
	
		
			2 Commits
		
	
	
		
			guide
			...
			remove-get
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|   | b692309c91 | ||
|   | a5a9658896 | 
| @@ -22,7 +22,6 @@ span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: | ||||
| .cs { color: #a2a2a2; font-style: italic } /* Comment.Special */ | ||||
| .gd { color: #777777 } /* Generic.Deleted */ | ||||
| .ge { color: #777777 } /* Generic.Emph */ | ||||
| .ges { color: #777777 } /* Generic.EmphStrong */ | ||||
| .gr { color: #777777 } /* Generic.Error */ | ||||
| .gh { color: #777777 } /* Generic.Heading */ | ||||
| .gi { color: #777777 } /* Generic.Inserted */ | ||||
|   | ||||
| @@ -1,8 +1,3 @@ | ||||
| sanic>=23.6.* | ||||
| sanic-ext>=23.6.* | ||||
| msgspec | ||||
| python-frontmatter | ||||
| pygments | ||||
| docstring-parser | ||||
| libsass | ||||
| mistune | ||||
|   | ||||
| @@ -1,11 +1,3 @@ | ||||
| """Sanic  User Guide | ||||
|  | ||||
| https://sanic.dev | ||||
|  | ||||
| Built using the SHH stack: | ||||
| - Sanic | ||||
| - html5tagger | ||||
| - HTMX""" | ||||
| from pathlib import Path | ||||
|  | ||||
| from webapp.worker.factory import create_app | ||||
|   | ||||
| @@ -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", | ||||
|   | ||||
| @@ -20,6 +20,7 @@ from pytest import LogCaptureFixture | ||||
|  | ||||
| from sanic import Request, Sanic | ||||
| from sanic.compat import Header | ||||
| from sanic.constants import DEFAULT_HTTP_CONTENT_TYPE | ||||
| from sanic.cookies import CookieJar | ||||
| from sanic.response import ( | ||||
|     HTTPResponse, | ||||
| @@ -545,7 +546,7 @@ def test_raw_response(app): | ||||
|         return raw(b"raw_response") | ||||
|  | ||||
|     request, response = app.test_client.get("/test") | ||||
|     assert response.content_type == "application/octet-stream" | ||||
|     assert response.content_type == DEFAULT_HTTP_CONTENT_TYPE | ||||
|     assert response.body == b"raw_response" | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -502,7 +502,7 @@ def test_dynamic_route_int(app): | ||||
|  | ||||
|     request, response = app.test_client.get("/folder/12345") | ||||
|     assert response.text == "OK" | ||||
|     assert type(results[0]) is int | ||||
|     assert isinstance(results[0], int) | ||||
|  | ||||
|     request, response = app.test_client.get("/folder/asdf") | ||||
|     assert response.status == 404 | ||||
| @@ -518,7 +518,7 @@ def test_dynamic_route_number(app): | ||||
|  | ||||
|     request, response = app.test_client.get("/weight/12345") | ||||
|     assert response.text == "OK" | ||||
|     assert type(results[0]) is float | ||||
|     assert isinstance(results[0], float) | ||||
|  | ||||
|     request, response = app.test_client.get("/weight/1234.56") | ||||
|     assert response.status == 200 | ||||
| @@ -567,7 +567,7 @@ def test_dynamic_route_uuid(app): | ||||
|     url = "/quirky/123e4567-e89b-12d3-a456-426655440000" | ||||
|     request, response = app.test_client.get(url) | ||||
|     assert response.text == "OK" | ||||
|     assert type(results[0]) is uuid.UUID | ||||
|     assert isinstance(results[0], uuid.UUID) | ||||
|  | ||||
|     generated_uuid = uuid.uuid4() | ||||
|     request, response = app.test_client.get(f"/quirky/{generated_uuid}") | ||||
| @@ -861,7 +861,7 @@ def test_dynamic_add_route_int(app): | ||||
|  | ||||
|     request, response = app.test_client.get("/folder/12345") | ||||
|     assert response.text == "OK" | ||||
|     assert type(results[0]) is int | ||||
|     assert isinstance(results[0], int) | ||||
|  | ||||
|     request, response = app.test_client.get("/folder/asdf") | ||||
|     assert response.status == 404 | ||||
| @@ -878,7 +878,7 @@ def test_dynamic_add_route_number(app): | ||||
|  | ||||
|     request, response = app.test_client.get("/weight/12345") | ||||
|     assert response.text == "OK" | ||||
|     assert type(results[0]) is float | ||||
|     assert isinstance(results[0], float) | ||||
|  | ||||
|     request, response = app.test_client.get("/weight/1234.56") | ||||
|     assert response.status == 200 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user