From dbd4c2882593f6118103120aa96fa9acdf7deedb Mon Sep 17 00:00:00 2001 From: subhajitsaha01 Date: Sat, 6 Sep 2025 22:01:22 +0530 Subject: [PATCH 1/4] Changed the static annotated type of select_jinja_autoescape method in src/flask/sansio/app.py --- src/flask/sansio/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/flask/sansio/app.py b/src/flask/sansio/app.py index a2592fe4..58cb8730 100644 --- a/src/flask/sansio/app.py +++ b/src/flask/sansio/app.py @@ -533,7 +533,7 @@ class App(Scaffold): """ return DispatchingJinjaLoader(self) - def select_jinja_autoescape(self, filename: str) -> bool: + def select_jinja_autoescape(self, filename: str | None) -> bool: """Returns ``True`` if autoescaping should be active for the given template name. If no template name is given, returns `True`. From 30da640ffe23b6e461fa91d387ffea6b9d9fa847 Mon Sep 17 00:00:00 2001 From: ADITYA SAH <134919531+adityasah104@users.noreply.github.com> Date: Sun, 25 Jan 2026 08:16:56 +0530 Subject: [PATCH 2/4] clarify 415 vs 400 errors for request.json (#5827) --- docs/patterns/javascript.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/patterns/javascript.rst b/docs/patterns/javascript.rst index d58a3eb6..b97ffc6d 100644 --- a/docs/patterns/javascript.rst +++ b/docs/patterns/javascript.rst @@ -136,7 +136,8 @@ In general, prefer sending request data as form data, as would be used when submitting an HTML form. JSON can represent more complex data, but unless you need that it's better to stick with the simpler format. When sending JSON data, the ``Content-Type: application/json`` header must be -sent as well, otherwise Flask will return a 400 error. +sent as well, otherwise Flask will return a 415 Unsupported Media Type +error. .. code-block:: javascript @@ -244,8 +245,9 @@ Receiving JSON in Views Use the :attr:`~flask.Request.json` property of the :data:`~flask.request` object to decode the request's body as JSON. If -the body is not valid JSON, or the ``Content-Type`` header is not set to -``application/json``, a 400 Bad Request error will be raised. +the body is not valid JSON, a 400 Bad Request error will be raised. If +the ``Content-Type`` header is not set to ``application/json``, a 415 +Unsupported Media Type error will be raised. .. code-block:: python From 709f83f6a32da8cdaec196d7b785ab6827322008 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Wed, 5 Nov 2025 18:13:26 +0100 Subject: [PATCH 3/4] pre-commit: Add codespell --- .pre-commit-config.yaml | 6 ++++++ pyproject.toml | 3 +++ 2 files changed, 9 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8549b016..63b3d53a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -8,6 +8,12 @@ repos: rev: 8afdb18d56d3bd3edea0c4ddde96965d6894f5f3 # frozen: 0.9.26 hooks: - id: uv-lock + - repo: https://github.com/codespell-project/codespell + rev: 63c8f8312b7559622c0d82815639671ae42132ac # frozen v2.4.1 + hooks: + - id: codespell + additional_dependencies: + - tomli - repo: https://github.com/pre-commit/pre-commit-hooks rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0 hooks: diff --git a/pyproject.toml b/pyproject.toml index 660239f9..20424de4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -166,6 +166,9 @@ select = [ force-single-line = true order-by-type = false +[tool.codespell] +ignore-words-list = "te" + [tool.tox] env_list = [ "py3.14", "py3.14t", From 3709c4a9a87e6ce8c26dc4a951e1df52ac9ecad0 Mon Sep 17 00:00:00 2001 From: David Lord Date: Sat, 24 Jan 2026 18:58:45 -0800 Subject: [PATCH 4/4] update ruff hook and noqa co-authored-by: Christian Clauss --- .pre-commit-config.yaml | 2 +- src/flask/app.py | 4 ++-- src/flask/sessions.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 63b3d53a..b1c2a876 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,7 +2,7 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit rev: 45ef068da5f21267bb2a7ec4a623092959f09ce5 # frozen: v0.14.14 hooks: - - id: ruff + - id: ruff-check - id: ruff-format - repo: https://github.com/astral-sh/uv-pre-commit rev: 8afdb18d56d3bd3edea0c4ddde96965d6894f5f3 # frozen: 0.9.26 diff --git a/src/flask/app.py b/src/flask/app.py index 1232b03d..c6dd7833 100644 --- a/src/flask/app.py +++ b/src/flask/app.py @@ -275,7 +275,7 @@ class Flask(App): f"{self.static_url_path}/", endpoint="static", host=static_host, - view_func=lambda **kw: self_ref().send_static_file(**kw), # type: ignore # noqa: B950 + view_func=lambda **kw: self_ref().send_static_file(**kw), # type: ignore ) def get_send_file_max_age(self, filename: str | None) -> int | None: @@ -1512,7 +1512,7 @@ class Flask(App): except Exception as e: error = e response = self.handle_exception(e) - except: # noqa: B001 + except: error = sys.exc_info()[1] raise return response(environ, start_response) diff --git a/src/flask/sessions.py b/src/flask/sessions.py index c1d978d3..1841d882 100644 --- a/src/flask/sessions.py +++ b/src/flask/sessions.py @@ -107,7 +107,7 @@ class NullSession(SecureCookieSession): "application to something unique and secret." ) - __setitem__ = __delitem__ = clear = pop = popitem = update = setdefault = _fail # noqa: B950 + __setitem__ = __delitem__ = clear = pop = popitem = update = setdefault = _fail del _fail