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

cached_property self type #9464

Open
cole-dda opened this issue Nov 14, 2024 · 1 comment
Open

cached_property self type #9464

cole-dda opened this issue Nov 14, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@cole-dda
Copy link

Environment data

  • Pylance version: v2024.11.2
  • OS and version: macos 12.7.6
  • Python version (& distribution if applicable, e.g. Anaconda): python3.12

Code Snippet

class CachedBug:

    @cached_property
    def x(self)->int:
        return 0
    
    @cached_property
    def y(self)->str:
        return ''
    
    @cached_property
    def z(self)->Self:
        return self.__class__()
    
    @cached_property
    def a(self)->'CachedBug':
        return CachedBug()

def usage():
    bug = CachedBug()
    #x is int,ok
    x = bug.x
    #y is str,ok
    y = bug.y
    
    #z is Any,not ok
    z = bug.z

    #a is CachedBug,ok
    a = bug.a

Repro Steps

  1. use vscode open python file

Expected behavior

pylance can know "z" is CachedBug type

Actual behavior

"z" is Any type

Logs

XXX
@erictraut
Copy link
Collaborator

Could someone from the pylance team please transfer this to the pyright project? Thanks!

@debonte debonte transferred this issue from microsoft/pylance-release Nov 14, 2024
@erictraut erictraut added the bug Something isn't working label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants