Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: simplify RequestOption construction in component factory #303

Merged

Conversation

ChristoGrab
Copy link
Collaborator

@ChristoGrab ChristoGrab commented Jan 30, 2025

What

Refactor components in the model_to_component factory that build child RequestOptions to leverage the re-usable _create_component_from_model method, rather than instantiating them with explicit attributes (ie, field_name). Hopefully this will reduce future tech debt if the RequestOption class is further modified moving forward.

Updates a couple tests to verify the behavior when using nested body_json injected values.

@ChristoGrab ChristoGrab requested a review from maxi297 January 30, 2025 23:21
@ChristoGrab ChristoGrab marked this pull request as ready for review January 30, 2025 23:50
@ChristoGrab ChristoGrab changed the title refactor: simplify RequestOption construction in component factory chore: simplify RequestOption construction in component factory Jan 30, 2025
Copy link
Contributor

@maxi297 maxi297 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Just a small nit

@@ -743,7 +745,7 @@ def test_datetime_based_cursor():
== "since_updated_at"
)
assert stream_slicer.end_time_option.inject_into == RequestOptionType.body_json
assert stream_slicer.end_time_option.field_name.eval({}) == "before_created_at"
assert stream_slicer.end_time_option.field_path[0].eval({}) == "before_created_at"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: The outcome could be that stream_slicer.end_time_option.field_path == ["before_created_at", "another dummy parameter that we don't expect"]. Should we change this to assert stream_slicer.end_time_option.field_path == ["before_created_at"]`?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, updated the test assertion

@github-actions github-actions bot added the chore label Jan 31, 2025
@ChristoGrab ChristoGrab merged commit 24264a0 into christo/request-option-field-path Jan 31, 2025
13 of 17 checks passed
@ChristoGrab ChristoGrab deleted the christo/debug-field-path branch January 31, 2025 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants