Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hot reload does not work within poetry scripts #329

Open
healplease opened this issue Mar 27, 2024 · 2 comments
Open

Hot reload does not work within poetry scripts #329

healplease opened this issue Mar 27, 2024 · 2 comments

Comments

@healplease
Copy link

When creating a Quart app using Poetry as a dependency manager and using Poetry to run a server with scripts, how reload fails to restart the app.

  1. Create Quart app using Poetry
  2. Add a script to pyproject.toml [tool.poetry.scripts] section that points to your app or app factory, like dev = helloworld:app. Make sure that app uses reloader, with snippet like this:

in app/serve.py

def dev() -> None:
    app = create_app()  # your implementation of app factory
    app.run(debug=True, use_reloader=True)

and in pyproject.toml

[tool.poetry.scripts]
dev = "app.serve:dev"
  1. Create a package with poetry install
  2. Run it with poetry run dev
  3. Save a file in your project to trigger hot reload

Expected result:
Project reloads, allowing you to see your changes immidiately

Observed result:
Project fails to reload with the next stacktrace

 * Serving Quart app 'qrt'
 * Debug mode: True
 * Please use an ASGI server (e.g. Hypercorn) directly in production
 * Running on http://127.0.0.1:5000 (CTRL + C to quit)
[2024-03-27 00:52:21 +0100] [14224] [INFO] Running on http://127.0.0.1:5000 (CTRL + C to quit)
  File "C:\Projects\Python\qrt\.venv\Scripts\dev.cmd", line 1
    @echo off
          ^^^
SyntaxError: invalid syntax

dev.cmd is a file created in your virtual environment by Poetry on poetry install (name of file same as the name of script in pyproject.toml) it tells poetry how to run the command and runs on hot reload, but it seems that file is treated as a Python script, while it should be treated as a Windows command-line script.

It seems as important bug to me since you recommend using Poetry for project management.

Environment:

  • OS: Windows 11
  • Python version: 3.12.2
  • Quart version: 0.19.4
@healplease
Copy link
Author

If you need an example of my Quart project: https://github.com/healplease/qrt

@davidism
Copy link
Member

This seems like something that needs to be reported to Poetry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants