zed icon indicating copy to clipboard operation
zed copied to clipboard

Python syntax server not working with Django's db.models class

Open arman29-dev opened this issue 9 months ago • 2 comments

Summary

Highlights an existing correct object as an error

Description

When I work with a Django project, it shows an error with every django.db.models's .objects. When I use any model object like <model>.objects.all() it underlines the .objects part with red and displays an error saying "Cannot access attribute "objects" for class "type[Product]" Attribute "objects" is unknown (Pyright reportAttributeAccessIssue)"

Expected Behavior: it should not display it as an error as objects is an object of models class. Actual Behavior: showing error on .objects

Zed Version and System Specs

Zed 0.187.9; Apple M2, 8GB RAM, OS15

arman29-dev avatar May 29 '25 00:05 arman29-dev

"Cannot access attribute "objects" for class "type[Product]" Attribute "objects" is unknown (Pyright reportAttributeAccessIssue)"

Does this happen in any other editors that use the same language server?

Zed is an editor and knows almost nothing about languages, including no info about "access", "attribute", "class", etc. — so the only potential issue could be here is that server being misconfigured (thus checking in other editors to be sure).

Apart from that, we cannot control which diagnostics the language server emits and how.

SomeoneToIgnore avatar May 29 '25 07:05 SomeoneToIgnore

No this does not happen in any other editor. I've used VSCode and Cursor. These editors never showed any error for this line of code. That was the reason I was hesitant to use zed at the 1st place but I eventually shifted to zed for its speed and light weight use.

arman29-dev avatar May 29 '25 08:05 arman29-dev

Image

I am also getting the same error but when using neovim. It is not technically an error since the attribute object exists in the instance of Product

Zaprovic avatar Jun 03 '25 02:06 Zaprovic

VSCode use Pyright under the hood but it's used inside its extension Pylance.

It must have some modification to make it works seamless with Django.

CedricRaison avatar Jun 03 '25 09:06 CedricRaison