-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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 an exception for IndexError
inside uninferable_final_decorator
#6532
Merged
Pierre-Sassoulas
merged 16 commits into
pylint-dev:main
from
mbyrnepr2:crash_uninferable_final_decorator
May 7, 2022
Merged
Changes from 3 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e7053b7
Add an exception for `IndexError` inside `uninferable_final_decoratorβ¦
mbyrnepr2 714c1d2
Apply suggestions from code review
Pierre-Sassoulas 8357070
Move changelog to 2.13.9
Pierre-Sassoulas 38cbeeb
Simplify the logic - Handle `IndexError` & `AttributeError` situations.
mbyrnepr2 071251d
Re-add the try-except to catch an `AttributeError`.
mbyrnepr2 64a5b75
Update tests/functional/r/regression/regression_6531_crash_index_erroβ¦
mbyrnepr2 42bcfc1
Remove try-except. Replace it with a `hasattr` check.
mbyrnepr2 d663879
Narrow the scope for error-handling
mbyrnepr2 6253936
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7dc1beb
rm Tuple
mbyrnepr2 1e35c35
typo
mbyrnepr2 547ab5e
Fix typing
mbyrnepr2 e2350df
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 8aedda2
import `typing.Union`
mbyrnepr2 83f696f
Fix the typing syntax.
mbyrnepr2 51a3df8
Only consider lookup when the module is named `typing`
mbyrnepr2 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
28 changes: 28 additions & 0 deletions
28
tests/functional/r/regression/regression_6531_crash_index_error.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,28 @@ | ||
# pylint: disable=missing-docstring, redefined-outer-name | ||
mbyrnepr2 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
import pytest | ||
|
||
|
||
class Wallet: | ||
def __init__(self): | ||
self.balance = 0 | ||
|
||
def add_cash(self, earned): | ||
self.balance += earned | ||
|
||
def spend_cash(self, spent): | ||
self.balance -= spent | ||
|
||
@pytest.fixture | ||
def my_wallet(): | ||
'''Returns a Wallet instance with a zero balance''' | ||
return Wallet() | ||
|
||
@pytest.mark.parametrize("earned,spent,expected", [ | ||
(30, 10, 20), | ||
(20, 2, 18), | ||
]) | ||
def test_transactions(my_wallet, earned, spent, expected): | ||
my_wallet.add_cash(earned) | ||
my_wallet.spend_cash(spent) | ||
assert my_wallet.balance == expected |
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.
I'm wondering if we should distinguish the two errors and try to handle the case where we can't do
[1][0]
. I guess Daniel will have an opinion :)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.
I believe the logic is simpler now with 38cbeeb & it more closely matches the
nodes.Name
case beneath it in the same function.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.
No, need to re-add the try-except since the primer test fails without it.