diff --git a/starlette/requests.py b/starlette/requests.py index 23f8ac70a..26c13d1ca 100644 --- a/starlette/requests.py +++ b/starlette/requests.py @@ -93,7 +93,7 @@ def app(self) -> typing.Any: @property def url(self) -> URL: - if not hasattr(self, "_url"): + if not hasattr(self, "_url"): # pragma: no branch self._url = URL(scope=self.scope) return self._url @@ -122,7 +122,7 @@ def headers(self) -> Headers: @property def query_params(self) -> QueryParams: - if not hasattr(self, "_query_params"): + if not hasattr(self, "_query_params"): # pragma: no branch self._query_params = QueryParams(self.scope["query_string"]) return self._query_params @@ -237,7 +237,7 @@ async def body(self) -> bytes: return self._body async def json(self) -> typing.Any: - if not hasattr(self, "_json"): + if not hasattr(self, "_json"): # pragma: no branch body = await self.body() self._json = json.loads(body) return self._json @@ -276,7 +276,7 @@ def form( return AwaitableOrContextManagerWrapper(self._get_form(max_files=max_files, max_fields=max_fields)) async def close(self) -> None: - if self._form is not None: + if self._form is not None: # pragma: no branch await self._form.close() async def is_disconnected(self) -> bool: diff --git a/tests/test_requests.py b/tests/test_requests.py index 02f29ee35..2f173713e 100644 --- a/tests/test_requests.py +++ b/tests/test_requests.py @@ -425,7 +425,7 @@ async def app(scope: Scope, receive: Receive, send: Send) -> None: # Browsers don't send extra whitespace or semicolons in Cookie headers, # but cookie_parser() should parse whitespace the same way # document.cookie parses whitespace. - # (" = b ; ; = ; c = ; ", {"": "b", "c": ""}), + (" = b ; ; = ; c = ; ", {"": "b", "c": ""}), ], ) def test_cookies_invalid(