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

Add support of field relashionsips on egg #5

Closed
wants to merge 2 commits into from

Conversation

brodokk
Copy link
Contributor

@brodokk brodokk commented Jun 27, 2023

This add support for the field relashionsips on the Egg models, useful for example when including more fields when using the include parameter from the eggs management endpoints

I also set a default values for the optional fields since a field must have a default value when using dataclass.

I also added a default argument for the field with the type Optional, since dataclass need a default value i think this will be requirement for the PyPI release #4

I also set a default values for the optional fields since a field must
have a default value when using dataclass.
@@ -229,7 +240,8 @@ class Egg:
startup: str
script: EggScript
created_at: str
updated_at: Optional[str]
updated_at: Optional[str] = None
relationships: Optional[dict] = None
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be Optional[EggRelationships]?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh my bad you right! Ok so the problem get more complicated that i was thinking. How you implemented for now doesn't give the ability to automatically use the type EggRelationships and will return a dict instead which make the typing wrong.

Maybe your usage of the library would be to convert it later? For now I removed it because I'm not sure if this is usefull or no but I think kept the default value for the Optional type is a good thing.

On one of my library i use https://github.com/konradhalas/dacite which could be a perfect usage here, but after some try a lot of the typing in your types classes are incompatible with the current version of pterodactyl API sadly. The only "problem" I can see is: this will be a breaking change since it will automatically return the correct type. For example Egg.config will return an EggConfiguration object instead of a dict, while it's what the typing say it will do.

I can make a PR for that if you want to test how it look on your end.

Copy link
Member

Choose a reason for hiding this comment

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

If it's returning a type that isn't what the type definition says, it's a bug, so I think it would be fine to implement this without it being a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hum ok, so what I propose then is: we can merge this one. I removed the EggRelationships class for now and will do another PR with everything patched then.

Copy link
Member

Choose a reason for hiding this comment

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

There's no need to remove it entirely – you can just implement the patch for type conversions in another PR. This can be closed for now.

@brodokk brodokk requested a review from devnote-dev July 3, 2023 16:56
@devnote-dev
Copy link
Member

Closing as per #5 (comment).

@devnote-dev devnote-dev closed this Jul 3, 2023
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