I am currently writing a Flask application and when i encounter an error i use this snippet so i instantly escape any code from within any function:
abort(make_response({"error": message}, 404))
I've now i wanted to move them to a separate file in wrapper functions so that i can have custom messages and status codes.
Now i have encounter this bug where Flask doesn't realize that my wrapper function causes the code to stop executing which can result in it showing errors that are not there.
Minimal Setup:
from flask import Flask, abort
app = Flask(__name__)
def function_that_causes_404():
abort(404)
@app.route("/pyrightbug")
def index():
function_that_causes_404()
return "Hello World" # it should say "Type analysis indicates code is unreachable" (see screenshot)
if __name__ == "__main__":
app.run()
Whats happening:
What should happen:
How i stumbled upon this bug:
(because Pyright doesn't understand that errors.no_JSON_provided() calls abort() it keeps analyzing where it shouldn't
The bug
I am currently writing a Flask application and when i encounter an error i use this snippet so i instantly escape any code from within any function:
I've now i wanted to move them to a separate file in wrapper functions so that i can have custom messages and status codes. Now i have encounter this bug where Flask doesn't realize that my wrapper function causes the code to stop executing which can result in it showing errors that are not there.
Minimal Setup:
Whats happening:
What should happen:
How i stumbled upon this bug:
(because Pyright doesn't understand that errors.no_JSON_provided() calls abort() it keeps analyzing where it shouldn't
Pyright version and environment
I am running Pyright version 1.1.389 inside of Neovim (my config can be found under https://github.com//TimmBmn/nvim-config)