-
Notifications
You must be signed in to change notification settings - Fork 17
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
feat: add publisher gateway client #240
base: main
Are you sure you want to change the base?
Conversation
This adds a very basic publisher gateway client that meets the needs of charmcraft's new 'create-track' command. The client cannot login yet and still depends on the old requests-based clients for many features.
c84c292
to
1eb2088
Compare
Retrieved from https://api.staging.charmhub.io/docs/default.html#create_tracks | ||
""" | ||
|
||
CreateTrackRequest = TypedDict( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it better to use MarshableModel
instead of TypedDict
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're trying to move away from generating and transforming the models all the time. This allows us to return the JSON dictionary returned by the store but still provide users with helpful details and linting during development.
At runtime, these are a no-op, but during development they offer both this:
and this:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't block you from delivering that, but for me it looks terrible and is really bug-prone - no validation at runtime unless you explicitly do it by yourself. No control over values returned from the store and
At least we should use a dataclass
-like regular syntax to make it somehow readable.
https://docs.python.org/3.12/library/typing.html#typing.TypedDict
I think at some point, we should also enforce using TypeAdapter
s for validating all the data that gets in and out:
https://docs.pydantic.dev/latest/concepts/type_adapter/#__tabbed_1_2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was my understanding of what @sergiusens intended - for us to be a pretty slim wrapper around the actual API. I think his intention was for us to pass the data structures as-is so that we don't need to update craft-store to be able to use additional properties that get added on the store side (either in the input or in the output).
94f002c
to
76986c4
Compare
76986c4
to
f06d037
Compare
f06d037
to
771e63c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good for me!
This adds a very basic publisher gateway client that meets the needs of charmcraft's new 'create-track' command.
The client cannot login yet and still depends on the old requests-based clients for many features.
Potentially resolves #239
CRAFT-3424
tox
?