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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pytero/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,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.


def __repr__(self) -> str:
return f'<Egg id={self.id} nest=#{self.nest} name={self.name}>'
Expand Down