forked from pylint-dev/pylint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c45d82e
commit 63e34c0
Showing
4 changed files
with
47 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
"""Tests for used-before-assignment with functions added in python 3.7""" | ||
# pylint: disable=missing-function-docstring | ||
from __future__ import annotations | ||
|
||
|
||
class MyClass: | ||
"""With the future import only default values can't refer to the base class""" | ||
|
||
def incorrect_method(self, other: MyClass) -> bool: | ||
return self == other | ||
|
||
def second_incorrect_method( | ||
self, other=MyClass() # [used-before-assignment] | ||
) -> bool: | ||
return self == other | ||
|
||
def correct_method(self, other: "MyClass") -> bool: | ||
return self == other | ||
|
||
def second_correct_method(self) -> bool: | ||
def inner_method(self, other: MyClass) -> bool: | ||
return self == other | ||
|
||
return inner_method(self, MyClass()) |
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,2 @@ | ||
[testoptions] | ||
min_pyver=3.7 |
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 @@ | ||
used-before-assignment:13:20:MyClass.second_incorrect_method:Using variable 'MyClass' before assignment:HIGH |