microsoft / vscode-python-debugger

Python debugger (debugpy) extension for VS Code.
https://marketplace.visualstudio.com/items?itemName=ms-python.debugpy
MIT License
41 stars 17 forks source link

TPI: Improve debug config selection in Flask #280

Closed paulacamargo25 closed 3 months ago

paulacamargo25 commented 3 months ago

Refs: https://github.com/microsoft/vscode-python-debugger/issues/161

Complexity: 3

Create Issue


Automatically detect a Flask file, and show it.

Steps

  1. Open a Flask Project if you already have one or you can also create one following the steps in the Flask Tutorial.

  2. Head over to the Run And Debug tab, and click on create a launch.json file.

    Screenshot 2024-03-24 at 11 31 32 AM
  3. A window will open with a list of options, choose Python Debugger > Flask.

Verification

  1. Valid flask file
    1. Verifies that your flask config file was found correctly and is displayed in the list.
    2. When you hover the item, verify that there is a button to open the file and that it works correctly.
    3. Select this option and verify that a launch.json configuration is created with the choose option.
  2. Invalid flask file (you can delete or change the name of the file)
    1. Since no file was found, verify that a Default option is displayed.
    2. Select this option and verify that a launch.json configuration is created with the choose option.
  3. Browse a file
    1. Click on the option Browse Files... and select the file that you want.
    2. Verify that a launch.json configuration is created with the choose option, and that the path has been parsed correctly.
  4. Add own value
    1. You can also include your own text, type a path in the input box and press enter.
    2. Verify that a launch.json configuration is created with the choose option.

Notes

Flask's application detection works by looking for the wsgi.py, app.py and init.py files in the root or in a subdirectory just one level lower and looking for them to have the declaration of a flask application app = Flask(. So you can try moving the python file and changing the name, and check that the detection still works.

jrieken commented 3 months ago

A window will open with a list of options, choose Python Debugger > Django.

@paulacamargo25 Are you sure about "Django"? Shouldn't it be "Flask"?

paulacamargo25 commented 3 months ago

A window will open with a list of options, choose Python Debugger > Django.

@paulacamargo25 Are you sure about "Django"? Shouldn't it be "Flask"?

Yes sorry, i just update the description