Skip to content
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

Fix incorrect behavior in argv.StoreInModule #389

Merged
merged 1 commit into from
Jul 28, 2016

Conversation

fahhem
Copy link
Collaborator

@fahhem fahhem commented Jul 28, 2016

Also document it now that it works :)

Previously, this would always try to set attributes in the openhtf module itself, not openhtf.util.logs or whichever module was correct.

Also document it now that it works :)

Previously, this would always try to set attributes in the openhtf module itself, not openhtf.util.logs or whichever module was correct.
@@ -19,5 +35,7 @@ def __init__(self, *args, **kwargs):
def __call__(self, parser, namespace, values, option_string=None):
if hasattr(self, '_proxy'):
values = self._proxy(parser, namespace, values)
setattr(__import__(self._tgt_mod), self._tgt_attr, values)
base, mod = self._tgt_mod.rsplit('.', 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This unpacking will break if the target module is already a base module without any dots, but arguably it doesn't make sense to use StoreInModule in such a case.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, yeah it's nonsensical to have no dots, but something one might accidentally do if you forget to do the %s/name business, maybe throw in a quick format check on the inputs of add_argument() to fail-fast rather than raise an obscure error here?

@grybmadsci
Copy link
Collaborator

LGTM, we'll get a merge conflict on station_api from the fix I threw in here, but farz's version is better, I think, mine was just a quick make-it-work fix:
https://github.com/google/openhtf/blob/station_api/openhtf/util/argv.py#L23

@jettisonjoe
Copy link
Contributor

I'm gonna merge this now so that the onus will be on me to resolve that conflict when rebasing station_api in prep for the PR to merge it into master. Created #390 to get a better error message if someone sets an unsuitable target.

@jettisonjoe jettisonjoe merged commit 2f231b3 into google:master Jul 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants