Skip to content
Myr

Don't set the cli attribute in the sansio scaffold

Before adoption: this commit came in with the history the project adopted, so no landing records it.

It is (currently) Flask specific and hence cannot be shared in the sansio shared code.

authored by pgjones · committed by David Lord · parent adb7dd9 · Browse files · 5 files+54 added−12 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

5 files+54 added−12 removed

  • other:+54 added−12 removed

5 files+54 added−12 removed

modified:src/flask/sansio/app.py-4 removed
408 unmodified lines
409 # tracks internally if the application already handled at least one410 # request.411 self._got_first_request = False412413 # Set the name of the Click group in case someone wants to add414 # the app's commands to another CLI tool.415 self.cli.name = self.name416413 def _check_setup_finished(self, f_name: str) -> None:414 if self._got_first_request:415 raise AssertionError(416 f"The setup method '{f_name}' can no longer be called"
548 unmodified lines
modified:src/flask/sansio/scaffold.py+4 added-8 removed
6 unmodified lines
7import typing as t8from collections import defaultdict9from functools import update_wrapper1011import click11from jinja2 import BaseLoader12from jinja2 import FileSystemLoader13from werkzeug.exceptions import default_exceptions14from werkzeug.exceptions import HTTPException15from werkzeug.utils import cached_property1617from .. import typing as ft19from ..cli import AppGroup18from ..helpers import get_root_path19from ..templating import _default_template_ctx_processor2021if t.TYPE_CHECKING: # pragma: no cover22 from click import Group2324# a singleton sentinel value for parameter defaults25_sentinel = object()2627F = t.TypeVar("F", bound=t.Callable[..., t.Any])
38 unmodified lines
6667 .. versionadded:: 2.068 """6970 cli: Group71 name: str72 _static_folder: str | None = None73 _static_url_path: str | None = None74
23 unmodified lines
98 #: Absolute path to the package on the filesystem. Used to look99 #: up resources contained in the package.100 self.root_path = root_path101100 #: The Click command group for registering CLI commands for this101 #: object. The commands are available from the ``flask`` command102 #: once the application has been discovered and blueprints have103 #: been registered.104 self.cli: click.Group = AppGroup()105102 #: A dictionary mapping endpoint names to view functions.103 #:104 #: To register a view function, use the :meth:`route` decorator.105 #:
696 unmodified lines
modified:src/flask/app.py+10 added
239 unmodified lines
240 instance_relative_config=instance_relative_config,241 root_path=root_path,242 )243244 #: The Click command group for registering CLI commands for this245 #: object. The commands are available from the ``flask`` command246 #: once the application has been discovered and blueprints have247 #: been registered.248 self.cli = cli.AppGroup()249250 # Set the name of the Click group in case someone wants to add251 # the app's commands to another CLI tool.252 self.cli.name = self.name253254 # Add a static route using the provided static_url_path, static_host,255 # and static_folder if there is a configured static_folder.256 # Note we do this without checking if static_folder exists.257 # For one, it might be created while the server is running (e.g. during
1241 unmodified lines
modified:src/flask/blueprints.py+38 added
2 unmodified lines
3import os4import typing as t5from datetime import timedelta67from .cli import AppGroup8from .globals import current_app9from .helpers import send_from_directory10from .sansio.blueprints import Blueprint as SansioBlueprint11from .sansio.blueprints import BlueprintSetupState as BlueprintSetupState # noqa12from .sansio.scaffold import _sentinel1314if t.TYPE_CHECKING: # pragma: no cover15 from .wrappers import Response161718class Blueprint(SansioBlueprint):19 def __init__(20 self,21 name: str,22 import_name: str,23 static_folder: str | os.PathLike[str] | None = None,24 static_url_path: str | None = None,25 template_folder: str | os.PathLike[str] | None = None,26 url_prefix: str | None = None,27 subdomain: str | None = None,28 url_defaults: dict[str, t.Any] | None = None,29 root_path: str | None = None,30 cli_group: str | None = _sentinel, # type: ignore31 ) -> None:32 super().__init__(33 name,34 import_name,35 static_folder,36 static_url_path,37 template_folder,38 url_prefix,39 subdomain,40 url_defaults,41 root_path,42 cli_group,43 )4445 #: The Click command group for registering CLI commands for this46 #: object. The commands are available from the ``flask`` command47 #: once the application has been discovered and blueprints have48 #: been registered.49 self.cli = AppGroup()5051 # Set the name of the Click group in case someone wants to add52 # the app's commands to another CLI tool.53 self.cli.name = self.name5455 def get_send_file_max_age(self, filename: str | None) -> int | None:56 """Used by :func:`send_file` to determine the ``max_age`` cache57 value for a given file path if it wasn't passed.58
71 unmodified lines
modified:CHANGES.rst+2 added
4 unmodified lines
56- The default ``hashlib.sha1`` may not be available in FIPS builds. Don't7 access it at import time so the developer has time to change the default.8 :issue:`5448`9- Don't initialize the ``cli`` attribute in the sansio scaffold, but rather in10 the ``Flask`` concrete class. :pr:`5270`111213Version 3.0.214-------------
1551 unmodified lines