pallets / quart

An async Python micro framework for building web applications.
https://quart.palletsprojects.com
MIT License
3.01k stars 164 forks source link

reload() puts comman name after command line arguments #328

Closed a1s closed 7 months ago

a1s commented 8 months ago

When Quart development server is run in auto-reload mode from a Python script, reload() puts the script name at the end of the command line. So the command line arguments are passed to the Python interpreter and not to the application script.

Example script:

import sys

import click
from quart import Quart

app = Quart(__file__)

@click.command()
@click.option("-c", "--config")
def run(config):
    click.echo(sys.argv)
    app.run(debug=True)

if __name__ == "__main__":
    run()

When this script is run with option -c whatever, auto-reload fails:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
NameError: name 'whatever' is not defined

Environment:

a1s commented 8 months ago

This fixes the error: reload.patch

pgjones commented 7 months ago

Thanks fixed in b2b7d48ad35a227dbd14ad6a6be694e595d215aa