DetachHead / basedpyright

pyright fork with various type checking improvements, improved vscode support and pylance features built into the language server
https://docs.basedpyright.com
Other
1.25k stars 26 forks source link

self and cls semantic highlighting #884

Open Kajiih opened 2 weeks ago

Kajiih commented 2 weeks ago

Hi, thanks for your great work !

I'm not very familiar with the topic, but in methods and class methods, self and cls are semantically considered as regular parameters in basedpyright (as opposed to Pylance).

Pylance: ![image](https://github.com/user-attachments/assets/44b6e919-6e39-4d1b-82e0-29cc7a21ddf4)
basepyright: ![image](https://github.com/user-attachments/assets/0f0ec6be-5bb7-4ad0-8a5b-89d5f6d4294d)

So in VS Code at least, the specific highlighting is overridden by the semantic highlighting of parameters, which I think is pretty sad 😢

Also, I'm not sure if it is linked, but in the playground, self and cls are highlighted differently:

playground: Screen Shot 2024-11-16 at 22 10 33

While we are at it, we can also notice a difference in how the decorators are interpreted, classmethod and absractmethod are considered as functions in basedpyright but class in Pylance. I'm not sure which one is the most logical or if it's a feature, but the basedpyright way seems the most natural to me.

DetachHead commented 2 weeks ago

Also, I'm not sure if it is linked, but in the playground, self and cls are highlighted differently:

the playground only has syntax highlighting which isn't handled by basedpyright but rather the monaco editor that it uses

While we are at it, we can also notice a difference in how the decorators are interpreted, classmethod and absractmethod are considered as functions in basedpyright but class in Pylance. I'm not sure which one is the most logical or if it's a feature, but the basedpyright way seems the most natural to me.

yeah this was intentional and was implemented by @ValdezFOmar in #217

Kajiih commented 2 weeks ago

Thanks for the clarification!