-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
pylint: fix misplaced-bare-raise #49018
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
Conversation
vamsi-verma-s
commented
Oct 10, 2022
- one of the issues in STYLE fix pylint issues #48855
- All code checks passed.
@@ -1983,7 +1983,7 @@ def _catch_deprecated_value_error(err: Exception) -> None: | |||
# IntervalDtype mismatched 'closed' | |||
pass | |||
elif "Timezones don't match" not in str(err): | |||
raise | |||
raise err |
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.
This would raise the exception anew and so lose the original traceback. Is that on purpose?
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.
missed that, it wasn't the intention. Do you think something like below would suffice?
raise err | |
raise ValueError(err) from err |
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.
please wait to merge, I think this is might be a bug in pylint
OK seems like e.g.
I think we can just ignore this inline, referencing this PR:
|
Hi @akx - are you sure about your With just Traceback (most recent call last):
File "/home/marcogorelli/pandas-dev/pandas/core/series.py", line 1116, in __setitem__
self._set_with_engine(key, value)
File "/home/marcogorelli/pandas-dev/pandas/core/series.py", line 1186, in _set_with_engine
loc = self.index.get_loc(key)
File "/home/marcogorelli/pandas-dev/pandas/core/indexes/range.py", line 395, in get_loc
self._check_indexing_error(key)
File "/home/marcogorelli/pandas-dev/pandas/core/indexes/base.py", line 6028, in _check_indexing_error
raise InvalidIndexError(key)
pandas.errors.InvalidIndexError: [False True False]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "t.py", line 51, in <module>
ser[mask] = 1
File "/home/marcogorelli/pandas-dev/pandas/core/series.py", line 1173, in __setitem__
self._where(~key, value, inplace=True)
File "/home/marcogorelli/pandas-dev/pandas/core/generic.py", line 9781, in _where
new_data = self._mgr.putmask(mask=cond, new=other, align=align)
File "/home/marcogorelli/pandas-dev/pandas/core/internals/managers.py", line 410, in putmask
return self.apply(
File "/home/marcogorelli/pandas-dev/pandas/core/internals/managers.py", line 350, in apply
applied = getattr(b, f)(**kwargs)
File "/home/marcogorelli/pandas-dev/pandas/core/internals/blocks.py", line 1534, in putmask
_catch_deprecated_value_error(err)
File "/home/marcogorelli/pandas-dev/pandas/core/internals/blocks.py", line 1532, in putmask
values._putmask(mask, new)
File "/home/marcogorelli/pandas-dev/pandas/core/arrays/string_.py", line 421, in _putmask
ExtensionArray._putmask(self, mask, value)
File "/home/marcogorelli/pandas-dev/pandas/core/arrays/base.py", line 1517, in _putmask
self[mask] = val
File "/home/marcogorelli/pandas-dev/pandas/core/arrays/string_.py", line 404, in __setitem__
raise ValueError(
ValueError: Cannot set non-string value '1' into a StringArray. with Traceback (most recent call last):
File "/home/marcogorelli/pandas-dev/pandas/core/series.py", line 1116, in __setitem__
self._set_with_engine(key, value)
File "/home/marcogorelli/pandas-dev/pandas/core/series.py", line 1186, in _set_with_engine
loc = self.index.get_loc(key)
File "/home/marcogorelli/pandas-dev/pandas/core/indexes/range.py", line 395, in get_loc
self._check_indexing_error(key)
File "/home/marcogorelli/pandas-dev/pandas/core/indexes/base.py", line 6028, in _check_indexing_error
raise InvalidIndexError(key)
pandas.errors.InvalidIndexError: [False True False]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "t.py", line 51, in <module>
ser[mask] = 1
File "/home/marcogorelli/pandas-dev/pandas/core/series.py", line 1173, in __setitem__
self._where(~key, value, inplace=True)
File "/home/marcogorelli/pandas-dev/pandas/core/generic.py", line 9781, in _where
new_data = self._mgr.putmask(mask=cond, new=other, align=align)
File "/home/marcogorelli/pandas-dev/pandas/core/internals/managers.py", line 410, in putmask
return self.apply(
File "/home/marcogorelli/pandas-dev/pandas/core/internals/managers.py", line 350, in apply
applied = getattr(b, f)(**kwargs)
File "/home/marcogorelli/pandas-dev/pandas/core/internals/blocks.py", line 1534, in putmask
_catch_deprecated_value_error(err)
File "/home/marcogorelli/pandas-dev/pandas/core/internals/blocks.py", line 1986, in _catch_deprecated_value_error
raise err # pylint: disable=misplaced-bare-raise GH49018
File "/home/marcogorelli/pandas-dev/pandas/core/internals/blocks.py", line 1532, in putmask
values._putmask(mask, new)
File "/home/marcogorelli/pandas-dev/pandas/core/arrays/string_.py", line 421, in _putmask
ExtensionArray._putmask(self, mask, value)
File "/home/marcogorelli/pandas-dev/pandas/core/arrays/base.py", line 1517, in _putmask
self[mask] = val
File "/home/marcogorelli/pandas-dev/pandas/core/arrays/string_.py", line 404, in __setitem__
raise ValueError(
ValueError: Cannot set non-string value '1' into a StringArray. So, I think it's fine to just do Code to trigger this: ser = pd.Series(["a", "b", "c"], dtype='string')
mask = np.array([False, True, False])
ser[mask] = 1 |
This reverts commit d633101.
I have reverted to original change. I was a bit confused here over loosing traceback. |
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.
Thanks @vamsi-verma-s
Thank you all for reviewing this. |
* pylint: fix misplaced-bare-raise * ignore pylint misplaced-bare-raise * Revert "ignore pylint misplaced-bare-raise" This reverts commit d633101.