--help flag does not work with QUART_APP envvar and create_app factory
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Bắt đầu bằng cách đọc luồng tải ứng dụng của Quart CLI trong quart/cli.py, đặc biệt là cách nó đọc QUART_APP và xử lý tùy chọn --help cấp cao nhất. Tái hiện bằng một factory create_app được chọn qua QUART_APP, rồi so sánh với --app. Hoàn tất khi QUART_APP=run quart --help hiển thị trợ giúp mà không có lỗi import, đồng thời các lệnh con được báo cáo vẫn hoạt động.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When using a create_app() factory function, the --help flag does not work with QUART_APP envvar but does work with --app flag. All other quart subcommands work such as 'run'.
Minimal example
Layout
.
├── init.py
├── run.py
└── server.py
server.py
from quart import Quart
def create_app(mode='Development'):
app = Quart(__name__)
print("hello from create_app")
return app
run.py
from .server import create_app
def main():
app = create_app()
app.run()
if __name__ == "__main__":
app.run()
Expected behaviour
% quart --app=run --help
hello from create_app
Usage: quart [OPTIONS] COMMAND [ARGS]...
A general utility script for Quart applications. An application to load must
be given with the '--app' option, 'QUART_APP' environment variable, or with
an 'app.py' file in the current directory.
Options:
-e, --env-file FILE Load environment variables from this file. python-
dotenv must be installed.
-A, --app IMPORT The QUART application or factory function to load, in
the form 'module:name'. Module can be a dotted import
or file path. Name is not required if it is 'app',
'application', 'create_app', or 'make_app', and can be
'name(args)' to pass arguments.
--debug / --no-debug Set 'app.debug' separately from '--env'.
--version Show the Quart version
--help Show this message and exit.
Commands:
routes Show the routes for the app.
run Run a development server.
shell Run a shell in the app context.
% quart --app=run run
hello from create_app
* Serving Quart app 'quarttest.server'
* Debug mode: False
* Please use an ASGI server (e.g. Hypercorn) directly in production
* Running on http://127.0.0.1:5000 (CTRL + C to quit)
Incorrect behaviour
% QUART_APP=run quart --help
Error: While importing 'quarttest.app', an ImportError was raised:
Traceback (most recent call last):
File "/Users/erikmelander/kod/quarttest/venv/lib/python3.11/site-packages/quart/cli.py", line 186, in locate_app
module = import_module(module_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'quarttest.app'
Usage: quart [OPTIONS] COMMAND [ARGS]...
A general utility script for Quart applications. An application to load must
be given with the '--app' option, 'QUART_APP' environment variable, or with
an 'app.py' file in the current directory.
Options:
-e, --env-file FILE Load environment variables from this file. python-
dotenv must be installed.
-A, --app IMPORT The QUART application or factory function to load, in
the form 'module:name'. Module can be a dotted import
or file path. Name is not required if it is 'app',
'application', 'create_app', or 'make_app', and can be
'name(args)' to pass arguments.
--debug / --no-debug Set 'app.debug' separately from '--env'.
--version Show the Quart version
--help Show this message and exit.
Commands:
routes Show the routes for the app.
run Run a development server.
shell Run a shell in the app context.
% QUART_APP=run quart run
hello from create_app
* Serving Quart app 'quarttest.server'
* Debug mode: False
* Please use an ASGI server (e.g. Hypercorn) directly in production
* Running on http://127.0.0.1:5000 (CTRL + C to quit)
Environment:
- Python version: 3.11
- Quart version: 0.22.0
- Ngôn ngữ chính
- Python
- Star
- 3.7k
- Fork
- 209
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của pallets/quart
-
`abort` typing doesn't accept Response as a valid parameterCó thể đã có người làm @touilleMan đã nhận 1478 ngày trước. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 68/100
-
process_response marks the session accessed, so every response gets Vary: CookieCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 78/100
-
Installing asgi_app middleware as documented results in type errorsCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
Allow max content length to be modified on a per-request basisCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
-
mypy: Blueprint type mismatch with `flask.sansio.blueprints.Blueprint`Có thể đã có người làm @hrimov đã nhận 641 ngày trước. Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Tất cả issue của pallets/quart
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
btclib-org/btclib#3062 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Run evals automatically in CIĐang mởarea:evals area:infra enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
jse-avl/support-bot#4 · 1 bình luận ·
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
qte77/agentic-job-offer-to-application-kit#487 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
On a free-threaded build, `_decrypted` can report a ledger locked mid-sign as a damaged fileĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
btclib-org/btclib-wallet#801 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation good first issue
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 94/100