Skip to content

Commit

Permalink
Merge pull request #6541 from janezd/inheriteq-stacklevel
Browse files Browse the repository at this point in the history
Improve stacklevel for warning about inherited eq for compute_value
  • Loading branch information
markotoplak committed Aug 22, 2023
2 parents eb3633c + 6ecdf12 commit 0906348
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Orange/data/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ def __init__(self, compute_shared, variable=None):
types.FunctionType)) \
and not redefines_eq_and_hash(compute_shared):
warnings.warn(f"{type(compute_shared).__name__} should define "
f"__eq__ and __hash__ to be used for compute_shared")
f"__eq__ and __hash__ to be used for compute_shared",
stacklevel=2)

def __call__(self, data, shared_data=None):
"""Fallback if common parts are not passed."""
Expand Down
3 changes: 2 additions & 1 deletion Orange/data/variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ def __init__(self, name="", compute_value=None, *, sparse=False):
and not type(compute_value).__dict__.get("InheritEq", False):
warnings.warn(f"{type(compute_value).__name__} should define "
"__eq__ and __hash__ to be used for compute_value\n"
"or set InheritEq = True if inherited methods suffice")
"or set InheritEq = True if inherited methods suffice",
stacklevel=3)

self._compute_value = compute_value
self.unknown_str = MISSING_VALUES
Expand Down

0 comments on commit 0906348

Please sign in to comment.