-
Notifications
You must be signed in to change notification settings - Fork 276
Semantic tokens doesn't classify properties with return annotations as properties #3066
Copy link
Copy link
Closed
astral-sh/ruff
#24065Labels
bugSomething isn't workingSomething isn't workingserverRelated to the LSP serverRelated to the LSP server
Milestone
Description
Summary
class Foo:
@property
def prop(self) -> int:
return 4
foo = Foo()
w = foo.prop # prop should be variable on an instanceSemantic tokens classify foo.prop as a variable instead of a property. The issue is that the classification is based on attribute_expression.inferred_type(...) but this returns a properties return type instead of the property (unless the property isn't annotated?).
I think we want to take an approach closer to basedpyright where we look at the declaration instead. This should also allow us to determine if the property is readonly or not.
This came up in astral-sh/ruff#23841 (comment)
Version
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingserverRelated to the LSP serverRelated to the LSP server