Refactor Endpoint Mixins for DRY and SOLID#681
Conversation
- Introduce `ClientProvider` protocol for dependency injection. - Refactor `ListEndpointMixin` to include `list` and `async_list` methods, reducing boilerplate in concrete classes. - Extract common setup logic in `ListEndpointMixin` to `_prepare_execution`. - Refactor `FilterGetEndpointMixin` and `PathGetEndpointMixin` to include `get` and `async_get` methods. - Simplify `GenericListEndpoint` and related base classes by removing redundant method wrappers. - Enforce strict typing with `mypy` and verify behavior with `pytest`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
- Introduce `ClientProvider` protocol for dependency injection. - Refactor `ListEndpointMixin` to include `list` and `async_list` methods, reducing boilerplate in concrete classes. - Extract common setup logic in `ListEndpointMixin` to `_prepare_execution`. - Refactor `FilterGetEndpointMixin` and `PathGetEndpointMixin` to include `get` and `async_get` methods. - Simplify `GenericListEndpoint` and related base classes by removing redundant method wrappers. - Enforce strict typing with `mypy` and verify behavior with `pytest`. - Fix formatting in `list.py` to pass `black` and `isort`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
- Introduce `ClientProvider` protocol for dependency injection. - Refactor `ListEndpointMixin` to include `list` and `async_list` methods, reducing boilerplate in concrete classes. - Extract common setup logic in `ListEndpointMixin` to `_prepare_execution`. - Refactor `FilterGetEndpointMixin` and `PathGetEndpointMixin` to include `get` and `async_get` methods. - Simplify `GenericListEndpoint` and related base classes by removing redundant method wrappers. - Enforce strict typing with `mypy` and verify behavior with `pytest`. - Fix formatting in `list.py` to pass `black` and `isort`. - Fix unused import in `list.py` to pass `ruff`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This PR refactors the endpoint mixins to adhere to DRY and SOLID principles. It moves the implementation of public
listandgetmethods into the mixins themselves, removing the need for boilerplate code inGeneric*Endpointclasses. It also introduces aClientProviderprotocol to make client dependencies explicit. TheListEndpointMixinnow uses a shared_prepare_executionmethod to handle common setup logic for both synchronous and asynchronous operations.PR created automatically by Jules for task 7964313980656361842 started by @fderuiter