| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 6f4f7f5 commit a36b8a5
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -530,7 +530,10 @@ def unmerged_blobs(self) -> Dict[PathLike, List[Tuple[StageType, Blob]]]: | |||
| 530 | 530 | stage. That is, a file removed on the 'other' branch whose entries are at | |
| 531 | 531 | stage 3 will not have a stage 3 entry. | |
| 532 | 532 | """ | |
| 533 | - is_unmerged_blob = lambda t: t[0] != 0 | ||
| 533 | + | ||
| 534 | + def is_unmerged_blob(t: Tuple[StageType, Blob]) -> bool: | ||
| 535 | + return t[0] != 0 | ||
| 536 | + | ||
| 534 | 537 | path_map: Dict[PathLike, List[Tuple[StageType, Blob]]] = {} | |
| 535 | 538 | for stage, blob in self.iter_blobs(is_unmerged_blob): | |
| 536 | 539 | path_map.setdefault(blob.path, []).append((stage, blob)) | |
@@ -690,12 +693,17 @@ def _store_path(self, filepath: PathLike, fprogress: Callable) -> BaseIndexEntry | |||
| 690 | 693 | This must be ensured in the calling code. | |
| 691 | 694 | """ | |
| 692 | 695 | st = os.lstat(filepath) # Handles non-symlinks as well. | |
| 696 | + | ||
| 693 | 697 | if S_ISLNK(st.st_mode): | |
| 694 | 698 | # In PY3, readlink is a string, but we need bytes. | |
| 695 | 699 | # In PY2, it was just OS encoded bytes, we assumed UTF-8. | |
| 696 | - open_stream: Callable[[], BinaryIO] = lambda: BytesIO(force_bytes(os.readlink(filepath), encoding=defenc)) | ||
| 700 | + def open_stream() -> BinaryIO: | ||
| 701 | + return BytesIO(force_bytes(os.readlink(filepath), encoding=defenc)) | ||
| 697 | 702 | else: | |
| 698 | - open_stream = lambda: open(filepath, "rb") | ||
| 703 | + | ||
| 704 | + def open_stream() -> BinaryIO: | ||
| 705 | + return open(filepath, "rb") | ||
| 706 | + | ||
| 699 | 707 | with open_stream() as stream: | |
| 700 | 708 | fprogress(filepath, False, filepath) | |
| 701 | 709 | istream = self.repo.odb.store(IStream(Blob.type, st.st_size, stream)) | |
@@ -1336,8 +1344,11 @@ def handle_stderr(proc: "Popen[bytes]", iter_checked_out_files: Iterable[PathLik | |||
| 1336 | 1344 | kwargs["as_process"] = True | |
| 1337 | 1345 | kwargs["istream"] = subprocess.PIPE | |
| 1338 | 1346 | proc = self.repo.git.checkout_index(args, **kwargs) | |
| 1347 | + | ||
| 1339 | 1348 | # FIXME: Reading from GIL! | |
| 1340 | - make_exc = lambda: GitCommandError(("git-checkout-index",) + tuple(args), 128, proc.stderr.read()) | ||
| 1349 | + def make_exc() -> GitCommandError: | ||
| 1350 | + return GitCommandError(("git-checkout-index", *args), 128, proc.stderr.read()) | ||
| 1351 | + | ||
| 1341 | 1352 | checked_out_files: List[PathLike] = [] | |
| 1342 | 1353 | ||
| 1343 | 1354 | for path in paths: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -50,7 +50,9 @@ | |||
| 50 | 50 | ||
| 51 | 51 | # -------------------------------------------------------- | |
| 52 | 52 | ||
| 53 | - cmp: Callable[[str, str], int] = lambda a, b: (a > b) - (a < b) | ||
| 53 | + | ||
| 54 | + def cmp(a: str, b: str) -> int: | ||
| 55 | + return (a > b) - (a < b) | ||
| 54 | 56 | ||
| 55 | 57 | ||
| 56 | 58 | class TreeModifier: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -66,7 +66,7 @@ lint.extend-select = [ | |||
| 66 | 66 | "TC004", # See: https://docs.astral.sh/ruff/rules/runtime-import-in-type-checking-block/ | |
| 67 | 67 | ] | |
| 68 | 68 | lint.ignore = [ | |
| 69 | - "E731", # Do not assign a `lambda` expression, use a `def` | ||
| 69 | + # If it becomes necessary to ignore any rules, list them here. | ||
| 70 | 70 | ] | |
| 71 | 71 | lint.unfixable = [ | |
| 72 | 72 | "F401", # Module imported but unused | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -243,6 +243,7 @@ def test_tree_traversal(self): | |||
| 243 | 243 | B_old = self.rorepo.tree("1f66cfbbce58b4b552b041707a12d437cc5f400a") # old base tree | |
| 244 | 244 | ||
| 245 | 245 | # Two very different trees. | |
| 246 | + | ||
| 246 | 247 | entries = traverse_trees_recursive(odb, [B_old.binsha, H.binsha], "") | |
| 247 | 248 | self._assert_tree_entries(entries, 2) | |
| 248 | 249 | ||
@@ -251,7 +252,10 @@ def test_tree_traversal(self): | |||
| 251 | 252 | self._assert_tree_entries(oentries, 2) | |
| 252 | 253 | ||
| 253 | 254 | # Single tree. | |
| 254 | - is_no_tree = lambda i, d: i.type != "tree" | ||
| 255 | + | ||
| 256 | + def is_no_tree(i, _d): | ||
| 257 | + return i.type != "tree" | ||
| 258 | + | ||
| 255 | 259 | entries = traverse_trees_recursive(odb, [B.binsha], "") | |
| 256 | 260 | assert len(entries) == len(list(B.traverse(predicate=is_no_tree))) | |
| 257 | 261 | self._assert_tree_entries(entries, 1) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -330,7 +330,10 @@ def test_index_file_from_tree(self, rw_repo): | |||
| 330 | 330 | assert len([e for e in three_way_index.entries.values() if e.stage != 0]) | |
| 331 | 331 | ||
| 332 | 332 | # ITERATE BLOBS | |
| 333 | - merge_required = lambda t: t[0] != 0 | ||
| 333 | + | ||
| 334 | + def merge_required(t): | ||
| 335 | + return t[0] != 0 | ||
| 336 | + | ||
| 334 | 337 | merge_blobs = list(three_way_index.iter_blobs(merge_required)) | |
| 335 | 338 | assert merge_blobs | |
| 336 | 339 | assert merge_blobs[0][0] in (1, 2, 3) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -126,12 +126,18 @@ def test_traverse(self): | |||
| 126 | 126 | assert len(list(root)) == len(list(root.traverse(depth=1))) | |
| 127 | 127 | ||
| 128 | 128 | # Only choose trees. | |
| 129 | - trees_only = lambda i, d: i.type == "tree" | ||
| 129 | + | ||
| 130 | + def trees_only(i, _d): | ||
| 131 | + return i.type == "tree" | ||
| 132 | + | ||
| 130 | 133 | trees = list(root.traverse(predicate=trees_only)) | |
| 131 | 134 | assert len(trees) == len([i for i in root.traverse() if trees_only(i, 0)]) | |
| 132 | 135 | ||
| 133 | 136 | # Test prune. | |
| 134 | - lib_folder = lambda t, d: t.path == "lib" | ||
| 137 | + | ||
| 138 | + def lib_folder(t, _d): | ||
| 139 | + return t.path == "lib" | ||
| 140 | + | ||
| 135 | 141 | pruned_trees = list(root.traverse(predicate=trees_only, prune=lib_folder)) | |
| 136 | 142 | assert len(pruned_trees) < len(trees) | |
| 137 | 143 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments