fastapi: Missing autocompletion for request.app
Describe the bug
When I am using the request instance in an endpoint, my IDE does not provide me with autocompletion for request.app.
Is it maybe due to missing type hints? Or because the request instance is from Starlette and cannot be annotated in FastAPI?
To Reproduce Steps to reproduce the behavior:
- Create a file with
from fastapi import FastAPI
from starlette.requests import Request
app = FastAPI()
@app.get('/')
def get(request: Request):
request.app
- Try to run autocompletion for request.app
Expected behavior I can use the auto-completion provided by me IDE (e.g. PyCharm)
Screenshots n/a
Environment:
-
OS: macOS
-
FastAPI Version: 0.42
-
Python version: 3.7.4
Additional context
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 1
- Comments: 17 (5 by maintainers)
I had two use cases for accessing fields of the
appinstance in a path operationThis would be solved by your suggestion to extract these values into a settings object.
I guess your same suggestion would apply here.
I am fine with that and I missed the proposed options when creating the issue.