-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
b502545
commit 900b7a4
Showing
5 changed files
with
62 additions
and
134 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
56 changes: 56 additions & 0 deletions
56
tests/functional/ext/function_return_not_assigned/function_return_not_assigned.py
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,56 @@ | ||
# pylint: disable=missing-function-docstring, missing-module-docstring, missing-class-docstring, expression-not-assigned, invalid-name | ||
from dataclasses import dataclass, replace | ||
|
||
|
||
def func_that_returns_something(): | ||
return 1 | ||
|
||
|
||
func_that_returns_something() # [function-return-not-assigned] | ||
|
||
_ = func_that_returns_something() | ||
|
||
if func_that_returns_something(): | ||
pass | ||
|
||
|
||
def func_that_returns_none(): | ||
return None | ||
|
||
|
||
def func_with_no_explicit_return(): | ||
print("I am doing something") | ||
|
||
|
||
func_that_returns_none() | ||
func_with_no_explicit_return() | ||
|
||
some_var = "" | ||
# next line should probably raise? | ||
func_that_returns_something() if some_var else func_that_returns_none() | ||
_ = func_that_returns_something() if some_var else func_that_returns_none() | ||
func_with_no_explicit_return() if some_var else func_that_returns_none() | ||
|
||
|
||
@dataclass | ||
class TestClass: | ||
value: int | ||
|
||
def return_self(self): | ||
return self | ||
|
||
def return_none(self): | ||
pass | ||
|
||
|
||
inst = TestClass(1) | ||
inst.return_self() # [function-return-not-assigned] | ||
inst.return_none() | ||
|
||
replace(inst, value=3) # [function-return-not-assigned] | ||
|
||
inst = replace(inst, value=3) | ||
|
||
inst.return_self() # [function-return-not-assigned] | ||
inst.return_none() | ||
inst = inst.return_self() |
2 changes: 2 additions & 0 deletions
2
tests/functional/ext/function_return_not_assigned/function_return_not_assigned.rc
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 @@ | ||
[MAIN] | ||
load-plugins=pylint.extensions.function_return_not_assigned, |
4 changes: 4 additions & 0 deletions
4
tests/functional/ext/function_return_not_assigned/function_return_not_assigned.txt
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,4 @@ | ||
function-return-not-assigned:9:0:9:29::Function returned value which is never used:UNDEFINED | ||
function-return-not-assigned:47:0:47:18::Function returned value which is never used:UNDEFINED | ||
function-return-not-assigned:50:0:50:22::Function returned value which is never used:UNDEFINED | ||
function-return-not-assigned:54:0:54:18::Function returned value which is never used:UNDEFINED |
Empty file.