From: Scott Gasch Date: Mon, 12 Jun 2023 19:09:15 +0000 (-0700) Subject: Remove useless lens. X-Git-Url: https://wannabe.guru.org/gitweb/?a=commitdiff_plain;h=9a3057c74c23611da36dfb7a1f3c41d67114666e;p=pyutils.git Remove useless lens. --- diff --git a/src/pyutils/config.py b/src/pyutils/config.py index 04e1498..f4647c4 100644 --- a/src/pyutils/config.py +++ b/src/pyutils/config.py @@ -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) diff --git a/src/pyutils/exec_utils.py b/src/pyutils/exec_utils.py index 2cb4fed..6839ef6 100644 --- a/src/pyutils/exec_utils.py +++ b/src/pyutils/exec_utils.py @@ -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() diff --git a/src/pyutils/geocode.py b/src/pyutils/geocode.py index e3e416e..004900e 100644 --- a/src/pyutils/geocode.py +++ b/src/pyutils/geocode.py @@ -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 diff --git a/src/pyutils/iter_utils.py b/src/pyutils/iter_utils.py index d48d959..3f693d5 100644 --- a/src/pyutils/iter_utils.py +++ b/src/pyutils/iter_utils.py @@ -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__() diff --git a/src/pyutils/string_utils.py b/src/pyutils/string_utils.py index bc2c611..22964c6 100644 --- a/src/pyutils/string_utils.py +++ b/src/pyutils/string_utils.py @@ -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