Conversation
PYD-181 Pydantic observability plugin
The idea is to support plugins from Pydantic, in a way we could "intercept", or "have hooks" on validation. For that, we intend to leverage the Entry Points Specification from Python. As a reference, the two most known entry points are for flake8 and pytest. The plugin needs to be agnostic i.e. it should just wrap the code we call the The implementation will be "hidden" in a fork. Questions
|
Deploying with
|
| Latest commit: |
e073168
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://720a4185.pydantic-docs2.pages.dev |
| Branch Preview URL: | https://kludex-pyd-181.pydantic-docs2.pages.dev |
|
please review |
samuelcolvin
left a comment
There was a problem hiding this comment.
otherwise I think this looks like a great start.
Obviously needs tests and documentation.
|
|
||
| def on_step(*args: Any, **kwargs: Any) -> None: | ||
| for plugin in plugins: | ||
| with contextlib.suppress(AttributeError, TypeError): |
There was a problem hiding this comment.
I'm not sure we should be suppressing these errors?
There was a problem hiding this comment.
Otherwise, I'll need more conditionals below to check if the steps are implemented, i.e. if on_event is not None and if step_func is not None. It's a bit more verbose.
What do you prefer?
|
@samuelcolvin Should I allow |
I've talked to @davidhewitt. I'll accept other keyword arguments for |
54a7612 to
f7c32d1
Compare
|
Only some tests missing here. |
|
please review |
Change Summary
Implement a plugin system using Python entry points.
Related issue number
Checklist
Missing
I'll add them if everything is fine with the current implementation.
PluggableSchemaValidatorSelected Reviewer: @samuelcolvin