Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Go to definition goes to stub files instead of actual definitions #4550

Closed
eshahbaz1 opened this issue Jun 28, 2023 · 1 comment
Closed

Go to definition goes to stub files instead of actual definitions #4550

eshahbaz1 opened this issue Jun 28, 2023 · 1 comment
Assignees
Labels
external bug typestub Issue relating to our bundled type stubs

Comments

@eshahbaz1
Copy link

eshahbaz1 commented Jun 28, 2023

Type: Bug

User.objects.get_or_create()

On the operator 'Go to Definition' for get_or_create it takes you to the declaration stub instead of the source code.

Steps to reproduce:

  1. Setup a dummy Django project with a User table and virtual env and install dependencies
  2. import a User model or any other model
  3. write User.objects.get_or_create() and click into get_or_create

You will get navigated to the pyi file instead of the source code from the Django library.

Extension version: v2023.6.30
VS Code Version: 1.79.2
Commit: 695af097c7bd098fbf017ce3ac85e09bbc5dda06
Date: 2023-06-14T08:58:33.551Z (1 wk ago)
Electron: 22.5.7
Chromium: 108.0.5359.215
Node.js: 16.17.1
V8: 10.8.168.25-electron.0
OS: Darwin arm64 22.5.0

@debonte
Copy link
Contributor

debonte commented Jun 28, 2023

@eshahbaz1, thanks for the issue. At runtime, Django is dynamically adding the QuerySet.get_or_create method to the Manager class. The Django stubs that are bundled with Pylance claim that get_or_create is a member of BaseManager, but it's not. I assume that they added it there as a work around for this dynamic behavior, so, for example, get_or_create would show up in completion suggestions. When you go to definition, Pylance can't navigate to QuerySet.get_or_create because it has no way of knowing that that's what is being called at runtime.

If you feel that the stubs should represent this in a different way, please file an issue at https://github.com/sbdchd/django-types/issues

@debonte debonte closed this as completed Jun 28, 2023
@debonte debonte added typestub Issue relating to our bundled type stubs external bug labels Jun 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external bug typestub Issue relating to our bundled type stubs
Projects
None yet
Development

No branches or pull requests

2 participants