-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement B037 check for yielding or returning values in __init__() (#…
…442) * Implement B037 check for yielding or returning values in __init__() * move return-in-init check to bugbearvisitor
- Loading branch information
Showing
4 changed files
with
80 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
|
||
class A: | ||
def __init__(self) -> None: | ||
return 1 # bad | ||
|
||
class B: | ||
def __init__(self, x) -> None: | ||
if x: | ||
return # ok | ||
else: | ||
return [] # bad | ||
|
||
class BNested: | ||
def __init__(self) -> None: | ||
yield # bad | ||
|
||
|
||
class C: | ||
def func(self): | ||
pass | ||
|
||
def __init__(self, k="") -> None: | ||
yield from [] # bad | ||
|
||
|
||
class D(C): | ||
def __init__(self, k="") -> None: | ||
super().__init__(k) | ||
return None # bad | ||
|
||
class E: | ||
def __init__(self) -> None: | ||
yield "a" |
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