drop end of life python versions

This commit is contained in:
David Lord 2025-05-13 08:31:54 -07:00
parent e7e5380776
commit 52df9eed45
No known key found for this signature in database
GPG key ID: 43368A7AA8CC5926
11 changed files with 78 additions and 284 deletions

View file

@ -601,15 +601,7 @@ class FlaskGroup(AppGroup):
if self._loaded_plugin_commands:
return
if sys.version_info >= (3, 10):
from importlib import metadata
else:
# Use a backport on Python < 3.10. We technically have
# importlib.metadata on 3.8+, but the API changed in 3.10,
# so use the backport for consistency.
import importlib_metadata as metadata # pyright: ignore
for ep in metadata.entry_points(group="flask.commands"):
for ep in importlib.metadata.entry_points(group="flask.commands"):
self.add_command(ep.load(), ep.name)
self._loaded_plugin_commands = True

View file

@ -135,7 +135,7 @@ class DefaultJSONProvider(JSONProvider):
method) will call the ``__html__`` method to get a string.
"""
default: t.Callable[[t.Any], t.Any] = staticmethod(_default) # type: ignore[assignment]
default: t.Callable[[t.Any], t.Any] = staticmethod(_default)
"""Apply this function to any object that :meth:`json.dumps` does
not know how to serialize. It should return a valid JSON type or
raise a ``TypeError``.

View file

@ -213,7 +213,7 @@ class App(Scaffold):
#:
#: This attribute can also be configured from the config with the
#: :data:`SECRET_KEY` configuration key. Defaults to ``None``.
secret_key = ConfigAttribute[t.Union[str, bytes, None]]("SECRET_KEY")
secret_key = ConfigAttribute[str | bytes | None]("SECRET_KEY")
#: A :class:`~datetime.timedelta` which is used to set the expiration
#: date of a permanent session. The default is 31 days which makes a

View file

@ -23,8 +23,7 @@ ResponseValue = t.Union[
]
# the possible types for an individual HTTP header
# This should be a Union, but mypy doesn't pass unless it's a TypeVar.
HeaderValue = t.Union[str, list[str], tuple[str, ...]]
HeaderValue = str | list[str] | tuple[str, ...]
# the possible types for HTTP headers
HeadersValue = t.Union[
@ -47,34 +46,29 @@ ResponseReturnValue = t.Union[
# callback annotated with flask.Response fail type checking.
ResponseClass = t.TypeVar("ResponseClass", bound="Response")
AppOrBlueprintKey = t.Optional[str] # The App key is None, whereas blueprints are named
AfterRequestCallable = t.Union[
t.Callable[[ResponseClass], ResponseClass],
t.Callable[[ResponseClass], t.Awaitable[ResponseClass]],
]
BeforeFirstRequestCallable = t.Union[
t.Callable[[], None], t.Callable[[], t.Awaitable[None]]
]
BeforeRequestCallable = t.Union[
t.Callable[[], t.Optional[ResponseReturnValue]],
t.Callable[[], t.Awaitable[t.Optional[ResponseReturnValue]]],
]
AppOrBlueprintKey = str | None # The App key is None, whereas blueprints are named
AfterRequestCallable = (
t.Callable[[ResponseClass], ResponseClass]
| t.Callable[[ResponseClass], t.Awaitable[ResponseClass]]
)
BeforeFirstRequestCallable = t.Callable[[], None] | t.Callable[[], t.Awaitable[None]]
BeforeRequestCallable = (
t.Callable[[], ResponseReturnValue | None]
| t.Callable[[], t.Awaitable[ResponseReturnValue | None]]
)
ShellContextProcessorCallable = t.Callable[[], dict[str, t.Any]]
TeardownCallable = t.Union[
t.Callable[[t.Optional[BaseException]], None],
t.Callable[[t.Optional[BaseException]], t.Awaitable[None]],
]
TemplateContextProcessorCallable = t.Union[
t.Callable[[], dict[str, t.Any]],
t.Callable[[], t.Awaitable[dict[str, t.Any]]],
]
TeardownCallable = (
t.Callable[[BaseException | None], None]
| t.Callable[[BaseException | None], t.Awaitable[None]]
)
TemplateContextProcessorCallable = (
t.Callable[[], dict[str, t.Any]] | t.Callable[[], t.Awaitable[dict[str, t.Any]]]
)
TemplateFilterCallable = t.Callable[..., t.Any]
TemplateGlobalCallable = t.Callable[..., t.Any]
TemplateTestCallable = t.Callable[..., bool]
URLDefaultCallable = t.Callable[[str, dict[str, t.Any]], None]
URLValuePreprocessorCallable = t.Callable[
[t.Optional[str], t.Optional[dict[str, t.Any]]], None
]
URLValuePreprocessorCallable = t.Callable[[str | None, dict[str, t.Any] | None], None]
# This should take Exception, but that either breaks typing the argument
# with a specific exception, or decorating multiple times with different
@ -82,12 +76,12 @@ URLValuePreprocessorCallable = t.Callable[
# https://github.com/pallets/flask/issues/4095
# https://github.com/pallets/flask/issues/4295
# https://github.com/pallets/flask/issues/4297
ErrorHandlerCallable = t.Union[
t.Callable[[t.Any], ResponseReturnValue],
t.Callable[[t.Any], t.Awaitable[ResponseReturnValue]],
]
ErrorHandlerCallable = (
t.Callable[[t.Any], ResponseReturnValue]
| t.Callable[[t.Any], t.Awaitable[ResponseReturnValue]]
)
RouteCallable = t.Union[
t.Callable[..., ResponseReturnValue],
t.Callable[..., t.Awaitable[ResponseReturnValue]],
]
RouteCallable = (
t.Callable[..., ResponseReturnValue]
| t.Callable[..., t.Awaitable[ResponseReturnValue]]
)