fix(checks)!: make Interact injection name-based#2302
Conversation
Replace the old type-based parameter injection with a name-based injectable for `inputs` and `trace`, supporting kw-only/pos-only/optional parameters and failing fast when required params are not injectable. Made-with: Cursor
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly refactors the parameter injection mechanism within the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request refactors the parameter injection mechanism by introducing a new injectable.py module, which defines ValueProvider and ValueGenerator classes. These new classes replace the previous ParameterInjectionRequirement, CallableInjectionMapping, and ValueGeneratorProvider structures, simplifying how parameters are injected into callables. The Interact class in interact.py is updated to use this new injection system, including changes to how input and output value providers are initialized and called, now expecting keyword arguments. Corresponding test files and README examples are updated to reflect the new inputs parameter naming convention and to include new test cases for keyword-only and positional-only parameters, ensuring the updated injection logic correctly handles various function signatures.
Inokinoki
left a comment
There was a problem hiding this comment.
LGTM.
Just that when I ran tests, it's saying that I did not enable the asyncio for pytest. Adding this fixes it:
[tool.pytest.ini_options]
asyncio_mode = "auto"
markers = [
Checking with the tests and the ways to use it now ;)
I added te config to root pyproject, should be good now. Thanks for the review |
Description
Replace the old type-based parameter injection with a name-based injectable for
inputsandtrace, simplifying the code and fixing issues due to type hint inspectionBreaking changes
When passing inputs/outpus function to
Interact, the signature must matchinputsandtracevariable name for injection mapping to work. Previously it was based on type hint.Related Issue
Fixes #2291