Skip to content
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

Fix exception causes in helpers.py #802

Merged
merged 1 commit into from
Jun 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions astroid/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ def _type_check(type1, type2):
return False
try:
return type1 in type2.mro()[:-1]
except exceptions.MroError:
except exceptions.MroError as e:
# The MRO is invalid.
raise exceptions._NonDeducibleTypeHierarchy
raise exceptions._NonDeducibleTypeHierarchy from e


def is_subtype(type1, type2):
Expand Down Expand Up @@ -261,10 +261,10 @@ def object_len(node, context=None):

try:
len_call = next(node_type.igetattr("__len__", context=context))
except exceptions.AttributeInferenceError:
except exceptions.AttributeInferenceError as e:
raise exceptions.AstroidTypeError(
"object of type '{}' has no len()".format(node_type.pytype())
)
) from e

result_of_len = next(len_call.infer_call_result(node, context))
if (
Expand Down