[pre-commit.ci lite] apply automatic fixes

This commit is contained in:
pre-commit-ci-lite[bot] 2025-11-29 04:46:38 +00:00 committed by GitHub
parent 37de8242a9
commit 0035afb7c7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 7 additions and 5 deletions

View file

@ -5,6 +5,7 @@ import inspect
import os import os
import sys import sys
import typing as t import typing as t
import warnings
import weakref import weakref
from datetime import timedelta from datetime import timedelta
from functools import update_wrapper from functools import update_wrapper
@ -12,7 +13,6 @@ from inspect import iscoroutinefunction
from itertools import chain from itertools import chain
from types import TracebackType from types import TracebackType
from urllib.parse import quote as _url_quote from urllib.parse import quote as _url_quote
import warnings
import click import click
from werkzeug.datastructures import Headers from werkzeug.datastructures import Headers
@ -252,8 +252,6 @@ class Flask(App):
session_interface: SessionInterface = SecureCookieSessionInterface() session_interface: SessionInterface = SecureCookieSessionInterface()
def __init_subclass__(cls, **kwargs: t.Any) -> None: def __init_subclass__(cls, **kwargs: t.Any) -> None:
import warnings
# These method signatures were updated to take a ctx param. Detect # These method signatures were updated to take a ctx param. Detect
# overridden methods in subclasses that still have the old signature. # overridden methods in subclasses that still have the old signature.
# Show a deprecation warning and wrap to call with correct args. # Show a deprecation warning and wrap to call with correct args.
@ -1598,7 +1596,6 @@ class Flask(App):
Kept for backwards compatibility it always returns False. Kept for backwards compatibility it always returns False.
""" """
import warnings
warnings.warn( warnings.warn(
"Flask.should_ignore_error is deprecated and will be removed in a " "Flask.should_ignore_error is deprecated and will be removed in a "
"future release. It currently always returns False and should not be used.", "future release. It currently always returns False and should not be used.",

View file

@ -1,12 +1,15 @@
import pytest import pytest
from flask import Flask from flask import Flask
def test_should_ignore_error_deprecation_warning(): def test_should_ignore_error_deprecation_warning():
"""Minimal test: check DeprecationWarning and return value.""" """Minimal test: check DeprecationWarning and return value."""
app = Flask(__name__) app = Flask(__name__)
with pytest.warns(DeprecationWarning): with pytest.warns(DeprecationWarning):
assert app.should_ignore_error(None) is False assert app.should_ignore_error(None) is False
@pytest.mark.parametrize("error", [Exception(), ValueError(), RuntimeError()]) @pytest.mark.parametrize("error", [Exception(), ValueError(), RuntimeError()])
def test_should_ignore_error_multiple_exceptions(error): def test_should_ignore_error_multiple_exceptions(error):
"""Verify that should_ignore_error issues a DeprecationWarning for multiple exception types.""" """Verify that should_ignore_error issues a DeprecationWarning for multiple exception types."""
@ -14,6 +17,7 @@ def test_should_ignore_error_multiple_exceptions(error):
with pytest.warns(DeprecationWarning): with pytest.warns(DeprecationWarning):
assert app.should_ignore_error(error) is False assert app.should_ignore_error(error) is False
def test_should_ignore_error_returns_false(): def test_should_ignore_error_returns_false():
"""Verify that should_ignore_error always returns False.""" """Verify that should_ignore_error always returns False."""
app = Flask(__name__) app = Flask(__name__)
@ -21,9 +25,10 @@ def test_should_ignore_error_returns_false():
result = app.should_ignore_error(Exception()) result = app.should_ignore_error(Exception())
assert result is False assert result is False
def test_should_ignore_error_warning_repeated_calls(): def test_should_ignore_error_warning_repeated_calls():
"""Verify repeated calls each trigger a DeprecationWarning.""" """Verify repeated calls each trigger a DeprecationWarning."""
app = Flask(__name__) app = Flask(__name__)
for _ in range(3): for _ in range(3):
with pytest.warns(DeprecationWarning): with pytest.warns(DeprecationWarning):
assert app.should_ignore_error(Exception()) is False assert app.should_ignore_error(Exception()) is False