-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
let Enums be actual rust Enums & split into modules #497
base: main
Are you sure you want to change the base?
Conversation
(at least youtube3 builds, the others get generated successfully)
(at least youtube3 builds, the others get generated successfully)
all apis libs build now
(this test currently fails and should be fixed at some point)
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 am currently a bit struggling with some cases where in most cases the stuff passed into schema_markers is a DictObject most of the time (during normal build every time currently) and a normal dict (during tests).
Is there a particular reason to not use the DictObject syntax and just access its values like in a normal dict?
I feel like this might just be a cosmetic/style issue but I am willing to adapt if you have some Idea how to get around this.
I think it's an oversight that a normal dict is passed during tests, maybe a conversion is missing?
These DictObjects are indeed just made for convenience, and I thought they make the code more readable. It's probably easiest to try to make sure everything is a DictObject as expected. |
The problem is I couldn't figure out how to reference the module from the tests. The DictObject is defined inside the mako_renderer which isn't really a normal python module (and my IDE normally doesn't even detect it as python code if I don't tell it). |
I see. Given how 'old-stable' this code is, I think it's fine the DictObject definition into the test code and use it there. That should be the easiest and most convenient. |
This reverts commit b9b8cec.
(copied version from `mako-render`)
This is needed since some builds do not remove old files and then cargo doesn't know which one to use. (for example GitHub-Actions)
I think I got most of the issues fixed. Currently I'm stumbling over a build error in This is the error:
and the same one is also happening on the main branch, so its not from my changes. One thing that is from my changes is that the values can no longer just be passed in as a string. They need to be converted to an enum if they really need to be strings or just be enums. These issues currently causes the CLIs not to build. |
It's interesting you are encountering the issue with Regarding the API change and the CLI compatibility, indeed that would mean one would have to provide a Thanks again for your great work here, it's awesome to see this improved. |
I already implemented the |
And I thought with the API providing
That's interesting, as I don't even know how this works in the existing code, or if it relies on a default value at all. Maybe the implementation on |
call = call.${mangle_ident(setter_fn_name(p))}(&value); | ||
} else { | ||
/*value was empty but has no default*/ | ||
todo!("I don't know what would be best in this situation.") |
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.
In this case the value provided was either empty or invalid and I'm not sure what to do in this case.
Should we just ignore this value and move on and see if it throws an error when executing the call?
Maybe output a warning?
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.
If it's possible to make the call anyway, the CLI could probably try it and maybe even emit a warning like you suggested.
Admittedly I don't fully understand this yet, but trying to be lenient for the CLI seems like the right choice here.
it was causing some issues and I want to focus on other things first.
if we get enum parameters that are required, but either missing without default or invalid, it panics currently. Maybe that can be improved if needed.
…name overlaps might happen
I found it quite impractical to always look up what options are available for each enum & pass the as strings, so I created this PR which turns the enums provided by the API into enums in Rust.
During this whole thing I had some problems with the file being quite large and my IDE struggling to not lag all the time, so I separated the individual parts into modules, which were currently only separated by a comment.
With this I can for example use
instead of
private
for the YouTube-API and actually get compiler errors when i misspelled something.
Note that I appended
Enum
to each enum name to reduce collisions with other existing types etc.I am open to Ideas and willing to put some time into this if any changes need to be made.