question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Missing autocompletion for request.app

See original GitHub issue

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:

  1. Create a file with
from fastapi import FastAPI
from starlette.requests import Request

app = FastAPI()

@app.get('/')
def get(request: Request):
    request.app
  1. 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

Screenshot 2019-10-21 09 07 57

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
chbndrhnnscommented, Feb 10, 2020

I had two use cases for accessing fields of the app instance in a path operation

  1. Redirecting based user agent
if any(browser in user_agent for browser in BROWSERS):
            return RedirectResponse(url=request.app.docs_url)
        return RedirectResponse(url=request.app.openapi_url)

This would be solved by your suggestion to extract these values into a settings object.

  1. Include app version into a path endpoint

I guess your same suggestion would apply here.

I am fine with that and I missed the proposed options when creating the issue.

0reactions
tiangolocommented, Feb 26, 2020

Great! Thanks for replying back @chbndrhnns . Then I think we can close this issue, right?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Xcode 13 autocomplete issues with overrides - Apple Developer
Let's say we are using UIViewController, and we are trying to override viewDidAppear. Typing viewDidAppear to override should get me the full function...
Read more >
Android Studio - Auto complete and other features not working
#1 From Build menu (of your Android Studio), click Rebuild Project option. #2 Then once rebuild completes, go to File > Invalidate Caches...
Read more >
Bug: Auto-complete doesn't work for Java in eclipse 2021-03
So I fixed the ini file. But autocomplete doesn't work. The first time I try it I get a popup that has just...
Read more >
How to turn off form autocompletion - Web security | MDN
This article explains how a website can disable autocomplete for form fields.
Read more >
370363 - autofill for forms not deactivatable - chromium
If the passwordfield is the first field in the form, it does not trigger. The form is even autofilled after adding autocomplete="off" into...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found