-
-
Notifications
You must be signed in to change notification settings - Fork 165
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
[ADD] except-pass: Emit message If a except:pass is used (OCA/#252) #107
Merged
moylop260
merged 2 commits into
OCA:master
from
vauxoo-dev:oca-master-add-except-pass-checker-jesuszapata
Feb 7, 2017
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,61 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Test Except Pass usage""" | ||
|
||
|
||
class TestExceptPass(object): | ||
"""Test Except Pass class """ | ||
|
||
def test_method(self): | ||
try: | ||
raise Exception('Exception') | ||
except Exception: # except-pass | ||
pass | ||
|
||
def test_2_method(self): | ||
"""This pass is skip for body of except has more than one line """ | ||
try: | ||
raise Exception('Exception') | ||
except Exception: | ||
pass | ||
print('Exception') | ||
|
||
def test_3_method(self): | ||
"""This pass is skip for the exception is assigned""" | ||
try: | ||
raise Exception('Exception') | ||
except Exception as exception: | ||
pass | ||
if exception: | ||
pass | ||
|
||
def test_4_method(self): | ||
try: | ||
raise Exception('Exception') | ||
except Exception, userError: | ||
pass | ||
if userError: | ||
pass | ||
|
||
def test_5_method(self): | ||
try: | ||
raise Exception('Exception') | ||
except (Exception, IndexError) as exception: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add the case where there are many Exceptions but without alias |
||
pass | ||
if exception: | ||
pass | ||
|
||
def test_6_method(self): | ||
try: | ||
raise Exception('Exception') | ||
except (Exception, IndexError): # except-pass | ||
pass | ||
|
||
def test_7_method(self): | ||
try: | ||
raise Exception('Exception') | ||
except (Exception, IndexError, NameError), exception: | ||
pass | ||
except Exception: # except-pass | ||
pass | ||
if exception: | ||
pass |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you could validate if the except has a
as
in order to skip the check because the new variable could be used.It this variable is not used then we will have a
variable-unused
from other checkThis is the easiest way to skip the check using the @lasley recommendation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@moylop260 @lasley
Done, Now we exclude if the exception is assigned to one variable