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

[Refactor] Extract index request factory #420

Merged
merged 3 commits into from
Dec 3, 2024

Conversation

jhamon
Copy link
Collaborator

@jhamon jhamon commented Dec 3, 2024

Problem

With my asyncio client in progress (not in this diff), I found myself needing to reuse a lot of the openapi request-building boilerplate.

Solution

Rather than copy/paste and create a lot of duplication, I want to pull that logic out into a separate class for building request objects. This change should not break existing behavior in the Index client.

Todo

This was pretty much just a mechanical extraction. I'd like to cleanup and standardize some stuff regarding _check_type, an openapi param that we're going to silly lengths to flip the default behavior on, in a follow-up diff.

Type of Change

  • None of the above: Refactor

Test Plan

Should still have tests passing

@@ -0,0 +1,30 @@
class IndexClientInstantiationError(Exception):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Since I was already in a mode of pulling things out of index.py, I decided to move this to a different file as well.

@jhamon jhamon marked this pull request as ready for review December 3, 2024 16:32
@jhamon jhamon requested a review from austin-denoble December 3, 2024 16:33
@jhamon jhamon assigned aulorbe and unassigned aulorbe Dec 3, 2024
@jhamon jhamon requested review from aulorbe and rohanshah18 December 3, 2024 16:34
Copy link
Contributor

@austin-denoble austin-denoble left a comment

Choose a reason for hiding this comment

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

Nice one, this makes a lot of sense given all the boilerplate we need to deal with to construct these requests.


class IndexRequestFactory:
@staticmethod
def query_request(
Copy link
Contributor

Choose a reason for hiding this comment

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

Good idea 👍 , I like encapsulating all of these helpers into a specific class.

@jhamon jhamon merged commit 79d8032 into release-candidate/2024-10 Dec 3, 2024
83 checks passed
@jhamon jhamon deleted the jhamon/extract-request-factory branch December 3, 2024 16:57
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.

3 participants