🛠️ Refactor: Endpoints - Explicit Study Key Strategy#770
🛠️ Refactor: Endpoints - Explicit Study Key Strategy#770
Conversation
Design Change: Replaced implicit boolean flags (`_pop_study_filter`) and exception attributes (`_missing_study_exception`) with explicit Strategy instances (`STUDY_KEY_STRATEGY = PopStudyKeyStrategy()`) on endpoint classes. Removed backward-compatible flag evaluation in `ParamMixin`. DRY Gains: Removed redundant attribute definitions in endpoints and simplified logic in `ParamMixin`'s property resolution. Solidity: Enforces Explicit > Implicit design (SOLID) by composing endpoints with concrete Strategy objects rather than relying on abstract mixins to evaluate hidden state flags. Breaking Changes: Removed `_pop_study_filter` and `_missing_study_exception` from `EndpointProtocol` and `ParamMixin`. Subclasses must now explicitly define `STUDY_KEY_STRATEGY`. 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. |
This PR refactors how
studyKeyhandling strategies are defined and resolved for SDK endpoints.Problem: Endpoints were relying on implicit class-level flags (
_pop_study_filter: booland_missing_study_exception: type[Exception]) whichParamMixinused dynamically to instantiate aStudyKeyStrategyvia backward compatibility logic. This violated the "Explicit > Implicit" rule and obscured the Strategy pattern.Solution:
_pop_study_filterand_missing_study_exceptionfromEndpointProtocolandParamMixin.ParamMixin.study_key_strategyto resolveself.STUDY_KEY_STRATEGYdirectly, defaulting toKeepStudyKeyStrategyorOptionalStudyKeyStrategybased solely onrequires_study_key.Codings,Forms,Intervals,Records,Sites,Users,Variables) to explicitly instantiate and assign the correctPopStudyKeyStrategyto theirSTUDY_KEY_STRATEGYattribute.Verification:
poetry run pytestpoetry run mypy src/imednetpoetry run black .andpoetry run ruff check --fix .PR created automatically by Jules for task 10957207828714997985 started by @fderuiter