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

Ensure apiVersion and kind are set for 'list' requests #68

Merged
merged 2 commits into from
Jul 1, 2024
Merged

Ensure apiVersion and kind are set for 'list' requests #68

merged 2 commits into from
Jul 1, 2024

Conversation

benfiola
Copy link
Contributor

These changes address the issue raised here.

Additionally, I:

  • Added a pytest.ini (- mainly because some IDEs use this to configure their unit testing integrations)
  • Added a dev extras to the setup.py that installs unit testing dependencies (pytest, pytest-asyncio, respx)
  • Updated .gitignore to ignore files used for my personal IDE (vscode + devcontainers)

@@ -192,6 +193,14 @@ def raise_for_status(resp):
def build_adapter_request(self, br: BasicRequest):
return self._client.build_request(br.method, br.url, params=br.params, json=br.data, headers=br.headers)

def convert_to_resource(self, res: Type[r.Resource], item: dict) -> r.Resource:
resource_def = res._api_info.resource
if not issubclass(res, dc_d.DataclassDictMixIn):
Copy link
Contributor Author

@benfiola benfiola Jun 30, 2024

Choose a reason for hiding this comment

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

Python's type system doesn't have a great way to provide multiple-inheritance/mixin-based types.

To help the typing system figure things out, I added this issubclass check. It's my understanding that all Type[r.Resource] objects are also DataclassDictMixIn objects - however, if this isn't the case, then this code will not work.

Copy link
Owner

Choose a reason for hiding this comment

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

I think we can just remove this test as it was not present before as well and anyway there is going to be a failure if from_dict is not defined (which should never be the case using standard resources or generic resources).

extras_require={
"dev": [
"pytest",
"pytest-asyncio<0.17.0",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks like pytest.mark.asyncio has been deprecated at some point (stackoverflow post) - consequently, I had to pin pytest-asyncio to an older version.

@gtsystem gtsystem merged commit 8399c0f into gtsystem:master Jul 1, 2024
3 of 9 checks passed
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.

2 participants