New auxiliary function to get value for options: _getopt()#555
New auxiliary function to get value for options: _getopt()#555leogama wants to merge 1 commit intouqfoundation:masterfrom
_getopt()#555Conversation
mmckerns
left a comment
There was a problem hiding this comment.
I'm not sure if this is a good idea in its current form.
| if arg is not None: | ||
| return arg | ||
| else: | ||
| return settings[key] |
There was a problem hiding this comment.
It's a bit unorthodox that the alternate is given as the first two values, and then the arg/kwd you are primarily interested in is given after that. Consider the syntax of getattr and similar.
So, this function pops key out of kwds (isn't get a better choice?), and if key is found and not None, then it is returned. If not found, then use arg if arg is provided, unless it's None... then default back to settings[key]. It's also expected that arg and kwds are never both given... so essentially, you have two one-liners in a single function, where any interaction between the two one-liners is an error. I'm not seeing the utility of this function, in that case. I could see using it, maybe, if you wanted to hide the import of settings within the function -- so _getopt(key, arg=None, *, kwds=None).
| self._byref = _getopt(settings, 'byref', kwds=kwds) | ||
| """ | ||
| # Sanity check, it's a bug in calling code if False. | ||
| assert kwds is None or arg is None |
There was a problem hiding this comment.
To me, an AssertionError is not expected... shouldn't it be a ValueError?
mmckerns
left a comment
There was a problem hiding this comment.
Please respond to the review comments.
From #475