-
Notifications
You must be signed in to change notification settings - Fork 87
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 the options data class to program #237
base: main
Are you sure you want to change the base?
Conversation
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.
Just some drive-by observations. Feel free to ignore!
Thanks, Berry 🙏 We welcome feedbacks and won't ignore anyone! |
Another TODO: Let's also update the code samples and show the best practice! |
Is there a way to add these as doctests so that the code samples must always be kept in working order? |
@warsawnv Totally. I'm actively working on getting github actions working, and the examples are invoked as part of the testsuite. |
/ok to test |
Very good point |
03128c8
to
6d789cb
Compare
…to ksimpson/add_program_options
/ok to test |
/ok to test |
/ok to test |
/ok to test |
last few comments addressed, tests improved and passing |
I still see many review comments above not addressed? |
one was an optional suggestion and one was a question. I didn't want to makr as resolved so you had a chance to see my response, but there weren't associated code changes |
…to ksimpson/add_program_options
… error number options
Thanks fcor pointing that out, and for the very in depth review which helped me find a couple issues as well as general improvements. I believe everything has now been addressed /ok to test |
/ok to test |
""" | ||
Check if the given object is a sequence (list or tuple). | ||
""" | ||
return isinstance(obj, (list, tuple)) |
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.
Q: Couldn't we just use isinstance(obj, Sequence)
here?
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.
no because a string is a sequence. That's what I originally wanted to do
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 why I left #237 (comment) and #237 (comment) above. str
is a nested sequence by our definition, because any of its elements is also a str
. If we check isinstance(something, str)
first to special case it, the remaining checks can be simplified and not specialized for any known container (list/tuple).
""" | ||
Check if the given object is a nested sequence (list or tuple with atleast one list or tuple element). | ||
""" | ||
return is_list_or_tuple(obj) and any(is_list_or_tuple(elem) for elem in obj) |
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.
ditto, also, it should be all
:
return is_list_or_tuple(obj) and any(is_list_or_tuple(elem) for elem in obj) | |
return is_list_or_tuple(obj) and all(is_list_or_tuple(elem) for elem in obj) |
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 think perhaps I should take this out of utils and leave it in program if it is too specific, but to handle the case in question it should be any imo, since I would like to support define_macro = ("MY_MACRO", ("MY_OTHER_MACRO", 99))
close #221
Add the options class to Program.
This comes with a few side effects, namely: There are some modifications to the tests, and the LinkerOptions class now accepts None for arch (using the current device as a default), for consistency between the program options and linker options