Adds a __repr__ to graph.
[pyutils.git] / src / pyutils / config.py
index 04e1498ac112e3b77a744ffdb188bcde239eaa66..a1aa5f97d89d9e3ebebe044436271dafef1a37a8 100644 (file)
@@ -403,6 +403,9 @@ class Config:
 
             Otherwise False is returned.
 
+        Raises:
+            Exception: On error reading from zookeeper
+
         >>> to_bool('True')
         True
 
@@ -455,7 +458,7 @@ class Config:
                     temp_argv.append(arg)
                     logger.info("Updating %s from zookeeper async config change.", arg)
 
-            if len(temp_argv) > 0:
+            if temp_argv:
                 old_argv = sys.argv
                 sys.argv = temp_argv
                 known, _ = ARGS.parse_known_args()
@@ -519,7 +522,7 @@ class Config:
             else:
                 saw_other_args = True
 
-        if not loadfile or len(loadfile) == 0:
+        if not loadfile:
             return
 
         # Get contents from wherever.
@@ -604,6 +607,10 @@ class Config:
             A dict containing the parsed program configuration.  Note that this can
                 be safely ignored since it is also saved in `config.config` and may
                 be used directly using that identifier.
+
+        Raises:
+            Exception: if unrecognized config argument(s) are detected and the
+                --config_rejects_unrecognized_arguments argument is enabled.
         """
         if self.config_parse_called:
             return self.config
@@ -635,7 +642,7 @@ class Config:
         # didn't recognize it, maybe someone else will.  Or, if
         # --config_rejects_unrecognized_arguments was passed, die
         # if we have unknown arguments.
-        if len(unknown) > 0:
+        if unknown:
             if config["config_rejects_unrecognized_arguments"]:
                 raise Exception(
                     f"Encountered unrecognized config argument(s) {unknown} with --config_rejects_unrecognized_arguments enabled; halting."
@@ -648,7 +655,7 @@ class Config:
 
         # Check for savefile and populate it if requested.
         savefile = config["config_savefile"]
-        if savefile and len(savefile) > 0:
+        if savefile:
             data = "\n".join(ORIG_ARGV[1:])
             if savefile[:3] == "zk:":
                 self._write_config_to_zookeeper(savefile[3:], data)