-
Notifications
You must be signed in to change notification settings - Fork 85
Aidan/clear has field type aliases #696
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
base: main
Are you sure you want to change the base?
Aidan/clear has field type aliases #696
Conversation
…for typing field manipulation functions Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
1ebaa01 to
411eb53
Compare
Add WhichOneofArgType and WhichOneofReturnType aliases Signed-off-by: Aidan Jensen <aidandj.github@gmail.com>
411eb53 to
b5dcfc2
Compare
|
WhichOneof type aliases ended up being simple. At first I was just going to number them, but then I realized that may not be static if new oneofs were added, unless i ordered them by field number. So I just appended the oneof name to the end of the field. All proto message names are valid python identifiers, so this was the safer, and more descriptive way. The name isn't always the prettiest, but its unique and descriptive. |
nipunn1313
left a comment
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.
oof complex impl, but seems good!
I've occasionally found myself wanting type aliases for these literals so you can properly type fields that call Clear or HasFields.
I'd like to do
Oneofas well, because then you can separate outOneofpattern match chains into separate functions.Oneofhas the type overloads though, and the aliases are slightly more complicated. That will be another PR.