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

Implement new reportIncompatibleVariableOverride #877

Closed
erictraut opened this issue Jul 23, 2020 · 5 comments
Closed

Implement new reportIncompatibleVariableOverride #877

erictraut opened this issue Jul 23, 2020 · 5 comments
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request

Comments

@erictraut
Copy link
Collaborator

Pyright currently supports a diagnostic rule called reportIncompatibleMethodOverride that detects when a subclass overrides a base class method in an incompatible way.

It would be useful to have a similar rule called reportIncompatibleVariableOverride that detects when a subclass declares an instance variable that is of an incompatible type. Properties and class variables will need to be taken into consideration.

For more thoughts, refer to this issue: microsoft/pylance-release#157 (comment)

@erictraut erictraut added the enhancement request New feature or request label Jul 23, 2020
@jakebailey
Copy link
Member

jakebailey commented Jul 23, 2020

For reference, this rule would not flag the code in #157 (actually) #867 as it would be "compatible", correct?

@erictraut
Copy link
Collaborator Author

No, it would still flag the code as in error because a property is not the same as a variable. They have different semantics. However, the user could disable this rule if they don't care about those semantic differences.

@jakebailey
Copy link
Member

Oh, this is my mistake. I meant the other override issue we had talked about previously, which is #867.

@erictraut
Copy link
Collaborator Author

Correct. reportIncompatibleMethodOverride would be specific to methods, and reportIncompatibleVariableOverride would be specific to non-method fields including instance variables and property objects.

@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Jul 26, 2020
@erictraut
Copy link
Collaborator Author

This is addressed in Pyright version 1.1.57, which I just published. It will also be included in the next version of Pylance.

heejaechang pushed a commit to heejaechang/pyright that referenced this issue Nov 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants