Remove useless lens.
authorScott Gasch <[email protected]>
Mon, 12 Jun 2023 19:09:15 +0000 (12:09 -0700)
committerScott Gasch <[email protected]>
Mon, 12 Jun 2023 19:09:15 +0000 (12:09 -0700)
src/pyutils/config.py
src/pyutils/exec_utils.py
src/pyutils/geocode.py
src/pyutils/iter_utils.py
src/pyutils/string_utils.py

index 04e1498ac112e3b77a744ffdb188bcde239eaa66..f4647c45eadc4907ff95165fe479b335fa80d1f3 100644 (file)
@@ -455,7 +455,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 +519,7 @@ class Config:
             else:
                 saw_other_args = True
 
-        if not loadfile or len(loadfile) == 0:
+        if not loadfile:
             return
 
         # Get contents from wherever.
@@ -635,7 +635,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 +648,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)
index 2cb4fede0fface6bbf65ad0e99449acabfbf68bd..6839ef6adf75c30cd2ededf8cff8b342f67914ee 100644 (file)
@@ -71,7 +71,7 @@ def cmd_showing_output(
                     char = key.fileobj.read(1)  # type: ignore
                     if not char:
                         sel.unregister(key.fileobj)
-                        if len(sel.get_map()) == 0:
+                        if not sel.get_map():
                             sys.stdout.flush()
                             sys.stderr.flush()
                             sel.close()
index e3e416e9ab84b487eeb17eb08ecf490b647a1d4d..004900e40c19e0df92e94f74d98fc3b32e9e65e4 100644 (file)
@@ -132,7 +132,7 @@ def batch_geocode_addresses(addresses: List[str]) -> Optional[List[str]]:
         logger.debug("Response: %s", r.text)
         for line in r.text.split("\n"):
             line = line.strip()
-            if len(line) > 0:
+            if line:
                 out.append(line)
     return out
 
index d48d95905dd7f536b16e43c4a7b687a80eb69495..3f693d54c59f181e1487facb445a6be708d34352 100644 (file)
@@ -52,7 +52,7 @@ class PeekingIterator(Iterator):
         return self
 
     def __next__(self) -> Any:
-        if len(self.on_deck) > 0:
+        if self.on_deck:
             return self.on_deck.pop()
         else:
             item = self.source_iter.__next__()
@@ -69,7 +69,7 @@ class PeekingIterator(Iterator):
             `StopIteration` when read.
 
         """
-        if len(self.on_deck) > 0:
+        if self.on_deck:
             return self.on_deck[0]
         try:
             item = next(self.source_iter)
@@ -115,7 +115,7 @@ class PushbackIterator(Iterator):
         return self
 
     def __next__(self) -> Any:
-        if len(self.pushed_back) > 0:
+        if self.pushed_back:
             return self.pushed_back.pop()
         return self.source_iter.__next__()
 
index bc2c6112de0e5ec70f548169842f371d7b5fe71b..22964c69041a5607075ce0907f59c55053b26d12 100644 (file)
@@ -731,7 +731,7 @@ def _add_thousands_separator(in_str: str, *, separator_char=',', places=3) -> st
         (in_str, decimal_part) = in_str.split('.')
     tmp = [iter(in_str[::-1])] * places
     ret = separator_char.join("".join(x) for x in zip_longest(*tmp, fillvalue=""))[::-1]
-    if len(decimal_part) > 0:
+    if decimal_part:
         ret += '.'
         ret += decimal_part
     return ret