-
Notifications
You must be signed in to change notification settings - Fork 767
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
Pylance ignore a final attribute overrides when base class is Exception #1495
Comments
The current behavior is by design. We could consider changing the design, but it is working as I would expect currently. When pylance performs its @Final override checks for methods, it takes into account the method resolution ordering (MRO) rules used in Python. MRO rules become especially important when multiple inheritance is used, like in your example above. In your example, the class Baz(Bar, Foo):
def __init__(self) -> None:
super().__init__()
print("BAZ") The output of this program is simply If you swap the order of the parameters within the class Baz(Foo, Bar): # Foo is first, then Bar
def __init__(self) -> None:
super().__init__()
print("BAZ") If you run this program, you'll now see the output PEP 591 (which defines the behavior of |
Maybe Pylance could forbid Assuming there is So I think the main conflict is not |
I've updated the code to check all base classes rather than simply using the MRO rules. This change affects all method and attribute override incompatibility checks plus @Final and constant checks. |
fixed in 2021.8.1 release. |
Environment data
Code Snippet / Additional information
The text was updated successfully, but these errors were encountered: