Skip to content
Myr

setup method on registered blueprint is error

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

authored by David Lord · committed by David Lord · parent 2a33c17 · Browse files · 2 files+8 added−13 removed
This commit

State

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

Diff stats

2 files+8 added−13 removed

  • other:+8 added−13 removed

2 files+8 added−13 removed

modified:src/flask/blueprints.py+6 added-13 removed
205 unmodified lines
206 self._blueprints: t.List[t.Tuple["Blueprint", dict]] = []207208 def _check_setup_finished(self, f_name: str) -> None:209 if self._got_registered_once:210 import warnings211212 warnings.warn(213 f"The setup method '{f_name}' can no longer be called on"214 f" the blueprint '{self.name}'. It has already been"215 " registered at least once, any changes will not be"216 " applied consistently.\n"217 "Make sure all imports, decorators, functions, etc."218 " needed to set up the blueprint are done before"219 " registering it.\n"220 "This warning will become an exception in Flask 2.3.",221 UserWarning,222 stacklevel=3,210 raise AssertionError(211 f"The setup method '{f_name}' can no longer be called on the blueprint"212 f" '{self.name}'. It has already been registered at least once, any"213 " changes will not be applied consistently.\n"214 "Make sure all imports, decorators, functions, etc. needed to set up"215 " the blueprint are done before registering it."216 )217218 @setupmethod219 def record(self, func: t.Callable) -> None:
402 unmodified lines
modified:CHANGES.rst+2 added
18 unmodified lines
19 are removed.20 - ``json_encoder`` and ``json_decoder`` attributes on app and blueprint, and the21 corresponding ``json.JSONEncoder`` and ``JSONDecoder`` classes, are removed.22 - The ``json.htmlsafe_dumps`` and ``htmlsafe_dump`` functions are removed.23 - Calling setup methods on blueprints after registration is an error instead of a24 warning. :pr:`4997`2526- Importing ``escape`` and ``Markup`` from ``flask`` is deprecated. Import them27 directly from ``markupsafe`` instead. :pr:`4996`28- The ``app.got_first_request`` property is deprecated. :pr:`4997`
1422 unmodified lines