-
Notifications
You must be signed in to change notification settings - Fork 124
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
[WIP] Issue 424/add saferepr #460
base: main
Are you sure you want to change the base?
[WIP] Issue 424/add saferepr #460
Conversation
testing/test_hookcaller.py
Outdated
# Intentional error to make the repr fail | ||
raise ValueError("Intentional error in he_method2") | ||
|
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 is not an error unable for the particular test
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 am not sure I understand the comment here, I am just trying to mock a random error so that we can test the saferepr implementation.
9e10722
to
5fa1164
Compare
35ede04
to
e6d20c6
Compare
2b10239
to
11d6c28
Compare
@@ -456,7 +457,7 @@ def _add_hookimpl(self, hookimpl: HookImpl) -> None: | |||
self._hookimpls.insert(i + 1, hookimpl) | |||
|
|||
def __repr__(self) -> str: | |||
return f"<HookCaller {self.name!r}>" |
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.
Why blindly replace all usages?
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.
as far as i can tell this pull request blindly replaces calls, but does not address the casting issue in the tracing code at all
based on the code as im looking at now, a simplified try/except based "safe str" is needed
also a test using tracing that traces a broken object as input is needed,
hook_impl = HookImpl(plugin, plugin_name, example_function, hook_impl_opts) | ||
|
||
# Verify attributes are set correctly | ||
assert hook_impl.function == example_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.
that type of test adds no value as far as can tell - lets keep experiments out of the codebase
|
||
# Verify __repr__ method | ||
expected_repr = ( | ||
f"<HookImpl plugin_name={saferepr(plugin_name)}, " f"plugin={saferepr(plugin)}>" |
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.
we shouldnt add safe-repr all over the place for everything
Description
An error was thrown after enabling tracing if one of the local objects lacked a specific outdated Scikit-Learn object. The issue asked to include error handling when outputting tracing messages for invalid string representations in order to increase the robustness of Pluggy’s error handling mechanism.
Solution
The saferepr module was implemented and adapted to Pluggy, as done in the Pytest repo. Saferepr includes a generous try...except clause along with additional error handling. This ensures that errors do not bubble up.
Steps to test
Link to issue
#424