-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added missing check for inconsistent use of
@final
in an overloaded…
… function. Added missing check for override of an overloaded method marked `@final`. This addresses #6860 and #6866.
- Loading branch information
Showing
6 changed files
with
179 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This sample tests that an overloaded method in a stub honors the | ||
# @final on the first overload. | ||
|
||
from typing import final, overload | ||
|
||
class ClassA: | ||
@overload | ||
@final | ||
def method1(self, x: int) -> int: ... | ||
@overload | ||
def method1(self, x: str) -> str: ... | ||
@overload | ||
def method2(self, x: int) -> int: ... | ||
@overload | ||
@final | ||
# This should generate an error because the first overload | ||
# is not marked @final but this one is. | ||
def method2(self, x: str) -> str: ... | ||
|
||
class ClassB(ClassA): | ||
@overload | ||
def method1(self, x: int) -> int: ... | ||
@overload | ||
# This should generate an error. | ||
def method1(self, x: str) -> str: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters