diff --git a/upstream_utils/update_eigen.py b/upstream_utils/update_eigen.py index 55d400db61..e04689a292 100755 --- a/upstream_utils/update_eigen.py +++ b/upstream_utils/update_eigen.py @@ -73,12 +73,8 @@ def eigen_inclusions(dp, f): ] modules_rgx = r"|".join("/" + m for m in modules) - # "Std" matches StdDeque, StdList, and StdVector headers - if re.search(modules_rgx, abspath) or "Std" in f: - return True - else: - # Exclude all other modules - return False + # "Std" matches StdDeque, StdList, and StdVector headers. Other modules are excluded. + return bool(re.search(modules_rgx, abspath) or "Std" in f) def unsupported_inclusions(dp, f): diff --git a/upstream_utils/update_llvm.py b/upstream_utils/update_llvm.py index 03e1f4d201..c2ebd124d4 100755 --- a/upstream_utils/update_llvm.py +++ b/upstream_utils/update_llvm.py @@ -126,12 +126,12 @@ def overwrite_files(wpiutil_files, llvm_files): for wpi_file in wpiutil_files: wpi_base_name = os.path.basename(wpi_file) - if wpi_base_name not in llvm_files: - if wpi_base_name not in unmatched_files_whitelist: - print(f"No file match for {wpi_file}, check if LLVM deleted it") - else: + if wpi_base_name in llvm_files: shutil.copyfile(llvm_files[wpi_base_name], wpi_file) + elif wpi_base_name not in unmatched_files_whitelist: + print(f"No file match for {wpi_file}, check if LLVM deleted it") + def overwrite_source(wpiutil_root, llvm_root): llvm_files = flattened_llvm_files( diff --git a/wpiutil/examples/printlog/datalog.py b/wpiutil/examples/printlog/datalog.py index 30a7dee714..b1035dd12b 100755 --- a/wpiutil/examples/printlog/datalog.py +++ b/wpiutil/examples/printlog/datalog.py @@ -153,17 +153,17 @@ class DataLogRecord: return arr def getStringArray(self) -> List[str]: - size = int.from_bytes(self.data[0:4], byteorder="little", signed=False) + size = int.from_bytes(self.data[:4], byteorder="little", signed=False) if size > ((len(self.data) - 4) / 4): raise TypeError("not a string array") arr = [] pos = 4 - for i in range(size): + for _ in range(size): val, pos = self._readInnerString(pos) arr.append(val) return arr - def _readInnerString(self, pos: int) -> str: + def _readInnerString(self, pos: int) -> tuple[str, int]: size = int.from_bytes( self.data[pos : pos + 4], byteorder="little", signed=False ) @@ -225,7 +225,7 @@ class DataLogReader: """Returns true if the data log is valid (e.g. has a valid header).""" return ( len(self.buf) >= 12 - and self.buf[0:6] == b"WPILOG" + and self.buf[:6] == b"WPILOG" and self.getVersion() >= 0x0100 ) @@ -307,7 +307,7 @@ if __name__ == "__main__": print("Unrecognized control record") else: print(f"Data({record.entry}, size={len(record.data)}) ", end="") - entry = entries.get(record.entry, None) + entry = entries.get(record.entry) if entry is None: print("") continue @@ -324,7 +324,7 @@ if __name__ == "__main__": print(f" {record.getDouble()}") elif entry.type == "int64": print(f" {record.getInteger()}") - elif entry.type == "string" or entry.type == "json": + elif entry.type in ("string", "json"): print(f" '{record.getString()}'") elif entry.type == "boolean": print(f" {record.getBoolean()}")