(Not relevant to the question itself, but the example uses quart-trio
package, which is similar in both interface and function to flask
.)
This code has no errors:
from quart_trio import QuartTrio
app = QuartTrio(__name__)
@app.route('/')
async def index() -> str:
return "ok"
app.run()
However, this code, which I assume would be identical, reports an issue:
from quart_trio import QuartTrio
def create_app() -> QuartTrio:
app = QuartTrio(__name__)
@app.route('/')
async def index() -> str: # error: Function "index" is not accessed (reportUnusedFunction)
return "ok"
return app
app = create_app()
app.run()
The same happens inside a method:
from quart_trio import QuartTrio
class Server:
def __init__(self) -> None:
super().__init__()
self.app = QuartTrio(__name__)
@self.app.route('/')
async def index() -> str: # error: Function "index" is not accessed (reportUnusedFunction)
return "ok"
def serve(self) -> None:
self.app.run()
Server().serve()
Anyone has an explanation? Is there a better way to write it that does not trigger the checker?