zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
45.46k stars 2.48k forks source link

Pyright cannot access attribute of a class `cached_property` #14371

Open calvinkawai opened 1 month ago

calvinkawai commented 1 month ago

Check for existing issues

Describe the bug / provide steps to reproduce it

I have a class similar in following structure, I want to go to definition of test function but pyright will throw error Cannot access attribute "test" for class "cached_property"   Attribute "test" is unknown


class A:

    @cached_property
    def foo(self):
           return B

    def f(self):
           # test is a function of B
           self.foo.test()

Environment

Zed: v0.143.7 (Zed) OS: macOS 14.5.0 Memory: 16 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your Zed.log file to this issue.

Zed.log


CharlesChen0823 commented 1 month ago

can you post a mini codebase for this?

calvinkawai commented 1 month ago

I just went through my code, I created something similar as code below and attach error image. I opened same code in Pycharm and it's fine to look up the definition.

from django.db import models
from django.utils.functional import cached_property

class Friend:

    def add_new_friend(self, person_id):
        print("add new friend")

# Create your models here.
class Person(models.Model):

    @cached_property
    def friend(self):
        return Friend()

    def add_me_to_friend_list(self)
        self.friend.add_new_friend(self.id)

Untitled

CharlesChen0823 commented 1 month ago

confirm that. not working with pyright, but in Pycharm and vscode, this work well.

And IMO, this is might pyright not supported this. because, using neovim with pyright, will also report this error.

calvinkawai commented 1 month ago

Is it possible changing to other language server?