fix: refactor init.py to improve structure, readability and API organization
This commit is contained in:
parent
2579ce9f18
commit
155de45a7f
1 changed files with 90 additions and 39 deletions
|
|
@ -1,39 +1,90 @@
|
||||||
from . import json as json
|
"""
|
||||||
from .app import Flask as Flask
|
Refactored convenience export module for the flask package.
|
||||||
from .blueprints import Blueprint as Blueprint
|
|
||||||
from .config import Config as Config
|
Principais mudanças:
|
||||||
from .ctx import after_this_request as after_this_request
|
- Removidos aliases redundantes do tipo `from .module import Name as Name`.
|
||||||
from .ctx import copy_current_request_context as copy_current_request_context
|
- Agrupados imports relacionados em blocos multi-linha legíveis.
|
||||||
from .ctx import has_app_context as has_app_context
|
- Adicionado __all__ explícito para indicar as exportações públicas do pacote
|
||||||
from .ctx import has_request_context as has_request_context
|
(isso ajuda linters a não reclamarem de "imported but unused").
|
||||||
from .globals import current_app as current_app
|
- Comentário explicando propósito do módulo.
|
||||||
from .globals import g as g
|
"""
|
||||||
from .globals import request as request
|
|
||||||
from .globals import session as session
|
from . import json
|
||||||
from .helpers import abort as abort
|
from .app import Flask
|
||||||
from .helpers import flash as flash
|
from .blueprints import Blueprint
|
||||||
from .helpers import get_flashed_messages as get_flashed_messages
|
from .config import Config
|
||||||
from .helpers import get_template_attribute as get_template_attribute
|
from .ctx import (
|
||||||
from .helpers import make_response as make_response
|
after_this_request,
|
||||||
from .helpers import redirect as redirect
|
copy_current_request_context,
|
||||||
from .helpers import send_file as send_file
|
has_app_context,
|
||||||
from .helpers import send_from_directory as send_from_directory
|
has_request_context,
|
||||||
from .helpers import stream_with_context as stream_with_context
|
)
|
||||||
from .helpers import url_for as url_for
|
from .globals import current_app, g, request, session
|
||||||
from .json import jsonify as jsonify
|
from .helpers import (
|
||||||
from .signals import appcontext_popped as appcontext_popped
|
abort,
|
||||||
from .signals import appcontext_pushed as appcontext_pushed
|
flash,
|
||||||
from .signals import appcontext_tearing_down as appcontext_tearing_down
|
get_flashed_messages,
|
||||||
from .signals import before_render_template as before_render_template
|
get_template_attribute,
|
||||||
from .signals import got_request_exception as got_request_exception
|
url_for,
|
||||||
from .signals import message_flashed as message_flashed
|
)
|
||||||
from .signals import request_finished as request_finished
|
from .json import jsonify
|
||||||
from .signals import request_started as request_started
|
from .logging import create_logger
|
||||||
from .signals import request_tearing_down as request_tearing_down
|
from .sansio.scaffold import Scaffold
|
||||||
from .signals import template_rendered as template_rendered
|
from .signals import (
|
||||||
from .templating import render_template as render_template
|
appcontext_popped,
|
||||||
from .templating import render_template_string as render_template_string
|
appcontext_pushed,
|
||||||
from .templating import stream_template as stream_template
|
appcontext_tearing_down,
|
||||||
from .templating import stream_template_string as stream_template_string
|
before_render_template,
|
||||||
from .wrappers import Request as Request
|
got_request_exception,
|
||||||
from .wrappers import Response as Response
|
message_flashed,
|
||||||
|
request_finished,
|
||||||
|
request_started,
|
||||||
|
request_tearing_down,
|
||||||
|
template_rendered,
|
||||||
|
)
|
||||||
|
from .templating import (
|
||||||
|
render_template,
|
||||||
|
render_template_string,
|
||||||
|
stream_template,
|
||||||
|
stream_template_string,
|
||||||
|
)
|
||||||
|
from .wrappers import Request, Response
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"json",
|
||||||
|
"Flask",
|
||||||
|
"Blueprint",
|
||||||
|
"Config",
|
||||||
|
"after_this_request",
|
||||||
|
"copy_current_request_context",
|
||||||
|
"has_app_context",
|
||||||
|
"has_request_context",
|
||||||
|
"current_app",
|
||||||
|
"g",
|
||||||
|
"request",
|
||||||
|
"session",
|
||||||
|
"abort",
|
||||||
|
"flash",
|
||||||
|
"get_flashed_messages",
|
||||||
|
"get_template_attribute",
|
||||||
|
"url_for",
|
||||||
|
"jsonify",
|
||||||
|
"create_logger",
|
||||||
|
"Scaffold",
|
||||||
|
"appcontext_popped",
|
||||||
|
"appcontext_pushed",
|
||||||
|
"appcontext_tearing_down",
|
||||||
|
"before_render_template",
|
||||||
|
"got_request_exception",
|
||||||
|
"message_flashed",
|
||||||
|
"request_finished",
|
||||||
|
"request_started",
|
||||||
|
"request_tearing_down",
|
||||||
|
"template_rendered",
|
||||||
|
"render_template",
|
||||||
|
"render_template_string",
|
||||||
|
"stream_template",
|
||||||
|
"stream_template_string",
|
||||||
|
"Request",
|
||||||
|
"Response",
|
||||||
|
]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue