We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Nicer failure mode for misuse of StoreInModule.
See #389.

> ...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

Document util/argv.py
There are no docs on how to use this module.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `openhtf/util/argv.py`
Content:
```
1 """Utilities for handling command line arguments.
2 
3 StoreInModule:
4   Enables emulating a gflags-esque API (flag affects global value), but one
5   doesn't necessarily need to use flags to set values.
6   
7   Example usage:
8     DEFAULT_VALUE = 0
9     ARG_PARSER = argv.ModuleParser()
10     ARG_PARSER.add_argument(
11         '--override-value', action=argv.StoreInModule,
12         default=DEFAULT_VALUE, target='%s.DEFAULT_VALUE' % __name__)
13 
14   Then in an entry point (main() function), use that parser as a parent:
15     parser = argparse.ArgumentParser(parents=[other_module.ARG_PARSER])
16     parser.parse_args()
17 """
18 
19 import argparse
20 
21 
22 def ModuleParser():
23     return argparse.ArgumentParser(add_help=False)
24 
25 
26 class StoreInModule(argparse.Action):
27 
28     def __init__(self, *args, **kwargs):
29         self._tgt_mod, self._tgt_attr = kwargs.pop('target').rsplit('.', 1)
30         proxy_cls = kwargs.pop('proxy', None)
31         if proxy_cls is not None:
32             self._proxy = proxy_cls(*args, **kwargs)
33         super(StoreInModule, self).__init__(*args, **kwargs)
34 
35     def __call__(self, parser, namespace, values, option_string=None):
36         if hasattr(self, '_proxy'):
37             values = self._proxy(parser, namespace, values)
38         base, mod = self._tgt_mod.rsplit('.', 1)
39         module = getattr(__import__(base, fromlist=[mod]), mod)
40         setattr(module, self._tgt_attr, values)
41 
42
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/openhtf/util/argv.py b/openhtf/util/argv.py
--- a/openhtf/util/argv.py
+++ b/openhtf/util/argv.py
@@ -35,7 +35,10 @@
     def __call__(self, parser, namespace, values, option_string=None):
         if hasattr(self, '_proxy'):
             values = self._proxy(parser, namespace, values)
-        base, mod = self._tgt_mod.rsplit('.', 1)
-        module = getattr(__import__(base, fromlist=[mod]), mod)
+        if '.' in self._tgt_mod:
+          base, mod = self._tgt_mod.rsplit('.', 1)
+          module = getattr(__import__(base, fromlist=[mod]), mod)
+        else:
+          module = __import__(self._tgt_mod)
         setattr(module, self._tgt_attr, values)

{"golden_diff": "diff --git a/openhtf/util/argv.py b/openhtf/util/argv.py\n--- a/openhtf/util/argv.py\n+++ b/openhtf/util/argv.py\n@@ -35,7 +35,10 @@\n     def __call__(self, parser, namespace, values, option_string=None):\n         if hasattr(self, '_proxy'):\n             values = self._proxy(parser, namespace, values)\n-        base, mod = self._tgt_mod.rsplit('.', 1)\n-        module = getattr(__import__(base, fromlist=[mod]), mod)\n+        if '.' in self._tgt_mod:\n+          base, mod = self._tgt_mod.rsplit('.', 1)\n+          module = getattr(__import__(base, fromlist=[mod]), mod)\n+        else:\n+          module = __import__(self._tgt_mod)\n         setattr(module, self._tgt_attr, values)\n", "issue": "Nicer failure mode for misuse of StoreInModule.\nSee #389.\n\n> ...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?\n> @grybmadsci\n\nDocument util/argv.py\nThere are no docs on how to use this module.\n\n", "before_files": [{"content": "\"\"\"Utilities for handling command line arguments.\n\nStoreInModule:\n  Enables emulating a gflags-esque API (flag affects global value), but one\n  doesn't necessarily need to use flags to set values.\n  \n  Example usage:\n    DEFAULT_VALUE = 0\n    ARG_PARSER = argv.ModuleParser()\n    ARG_PARSER.add_argument(\n        '--override-value', action=argv.StoreInModule,\n        default=DEFAULT_VALUE, target='%s.DEFAULT_VALUE' % __name__)\n\n  Then in an entry point (main() function), use that parser as a parent:\n    parser = argparse.ArgumentParser(parents=[other_module.ARG_PARSER])\n    parser.parse_args()\n\"\"\"\n\nimport argparse\n\n\ndef ModuleParser():\n    return argparse.ArgumentParser(add_help=False)\n\n\nclass StoreInModule(argparse.Action):\n\n    def __init__(self, *args, **kwargs):\n        self._tgt_mod, self._tgt_attr = kwargs.pop('target').rsplit('.', 1)\n        proxy_cls = kwargs.pop('proxy', None)\n        if proxy_cls is not None:\n            self._proxy = proxy_cls(*args, **kwargs)\n        super(StoreInModule, self).__init__(*args, **kwargs)\n\n    def __call__(self, parser, namespace, values, option_string=None):\n        if hasattr(self, '_proxy'):\n            values = self._proxy(parser, namespace, values)\n        base, mod = self._tgt_mod.rsplit('.', 1)\n        module = getattr(__import__(base, fromlist=[mod]), mod)\n        setattr(module, self._tgt_attr, values)\n\n", "path": "openhtf/util/argv.py"}], "after_files": [{"content": "\"\"\"Utilities for handling command line arguments.\n\nStoreInModule:\n  Enables emulating a gflags-esque API (flag affects global value), but one\n  doesn't necessarily need to use flags to set values.\n  \n  Example usage:\n    DEFAULT_VALUE = 0\n    ARG_PARSER = argv.ModuleParser()\n    ARG_PARSER.add_argument(\n        '--override-value', action=argv.StoreInModule,\n        default=DEFAULT_VALUE, target='%s.DEFAULT_VALUE' % __name__)\n\n  Then in an entry point (main() function), use that parser as a parent:\n    parser = argparse.ArgumentParser(parents=[other_module.ARG_PARSER])\n    parser.parse_args()\n\"\"\"\n\nimport argparse\n\n\ndef ModuleParser():\n    return argparse.ArgumentParser(add_help=False)\n\n\nclass StoreInModule(argparse.Action):\n\n    def __init__(self, *args, **kwargs):\n        self._tgt_mod, self._tgt_attr = kwargs.pop('target').rsplit('.', 1)\n        proxy_cls = kwargs.pop('proxy', None)\n        if proxy_cls is not None:\n            self._proxy = proxy_cls(*args, **kwargs)\n        super(StoreInModule, self).__init__(*args, **kwargs)\n\n    def __call__(self, parser, namespace, values, option_string=None):\n        if hasattr(self, '_proxy'):\n            values = self._proxy(parser, namespace, values)\n        if '.' in self._tgt_mod:\n          base, mod = self._tgt_mod.rsplit('.', 1)\n          module = getattr(__import__(base, fromlist=[mod]), mod)\n        else:\n          module = __import__(self._tgt_mod)\n        setattr(module, self._tgt_attr, values)\n\n", "path": "openhtf/util/argv.py"}]}