Skip to content

🛠️ Refactor: Endpoints - Explicit Study Key Strategy#770

Draft
fderuiter wants to merge 1 commit intomainfrom
refactor-study-key-strategy-10957207828714997985
Draft

🛠️ Refactor: Endpoints - Explicit Study Key Strategy#770
fderuiter wants to merge 1 commit intomainfrom
refactor-study-key-strategy-10957207828714997985

Conversation

@fderuiter
Copy link
Copy Markdown
Owner

This PR refactors how studyKey handling strategies are defined and resolved for SDK endpoints.

Problem: Endpoints were relying on implicit class-level flags (_pop_study_filter: bool and _missing_study_exception: type[Exception]) which ParamMixin used dynamically to instantiate a StudyKeyStrategy via backward compatibility logic. This violated the "Explicit > Implicit" rule and obscured the Strategy pattern.

Solution:

  1. Removed _pop_study_filter and _missing_study_exception from EndpointProtocol and ParamMixin.
  2. Updated ParamMixin.study_key_strategy to resolve self.STUDY_KEY_STRATEGY directly, defaulting to KeepStudyKeyStrategy or OptionalStudyKeyStrategy based solely on requires_study_key.
  3. Updated all relevant endpoints (Codings, Forms, Intervals, Records, Sites, Users, Variables) to explicitly instantiate and assign the correct PopStudyKeyStrategy to their STUDY_KEY_STRATEGY attribute.

Verification:

  • Tests pass: poetry run pytest
  • Type checks pass: poetry run mypy src/imednet
  • Formatting checks pass: poetry run black . and poetry run ruff check --fix .

PR created automatically by Jules for task 10957207828714997985 started by @fderuiter

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>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant