Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit17d53b0

Browse files
authored
Merge pull request#2049 from EliahKagan/style
Various style improvements
2 parents646dc16 +a36b8a5 commit17d53b0

File tree

7 files changed

+48
-24
lines changed

7 files changed

+48
-24
lines changed

‎git/index/base.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,10 @@ def unmerged_blobs(self) -> Dict[PathLike, List[Tuple[StageType, Blob]]]:
530530
stage. That is, a file removed on the 'other' branch whose entries are at
531531
stage 3 will not have a stage 3 entry.
532532
"""
533-
is_unmerged_blob=lambdat:t[0]!=0
533+
534+
defis_unmerged_blob(t:Tuple[StageType,Blob])->bool:
535+
returnt[0]!=0
536+
534537
path_map:Dict[PathLike,List[Tuple[StageType,Blob]]]= {}
535538
forstage,blobinself.iter_blobs(is_unmerged_blob):
536539
path_map.setdefault(blob.path, []).append((stage,blob))
@@ -690,12 +693,17 @@ def _store_path(self, filepath: PathLike, fprogress: Callable) -> BaseIndexEntry
690693
This must be ensured in the calling code.
691694
"""
692695
st=os.lstat(filepath)# Handles non-symlinks as well.
696+
693697
ifS_ISLNK(st.st_mode):
694698
# In PY3, readlink is a string, but we need bytes.
695699
# 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+
defopen_stream()->BinaryIO:
701+
returnBytesIO(force_bytes(os.readlink(filepath),encoding=defenc))
697702
else:
698-
open_stream=lambda:open(filepath,"rb")
703+
704+
defopen_stream()->BinaryIO:
705+
returnopen(filepath,"rb")
706+
699707
withopen_stream()asstream:
700708
fprogress(filepath,False,filepath)
701709
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
13361344
kwargs["as_process"]=True
13371345
kwargs["istream"]=subprocess.PIPE
13381346
proc=self.repo.git.checkout_index(args,**kwargs)
1347+
13391348
# FIXME: Reading from GIL!
1340-
make_exc=lambda:GitCommandError(("git-checkout-index",)+tuple(args),128,proc.stderr.read())
1349+
defmake_exc()->GitCommandError:
1350+
returnGitCommandError(("git-checkout-index",*args),128,proc.stderr.read())
1351+
13411352
checked_out_files:List[PathLike]= []
13421353

13431354
forpathinpaths:

‎git/objects/tree.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@
5050

5151
# --------------------------------------------------------
5252

53-
cmp:Callable[[str,str],int]=lambdaa,b: (a>b)- (a<b)
53+
54+
defcmp(a:str,b:str)->int:
55+
return (a>b)- (a<b)
5456

5557

5658
classTreeModifier:

‎pyproject.toml

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,14 @@ lint.select = [
6060
# "UP", # See: https://docs.astral.sh/ruff/rules/#pyupgrade-up
6161
]
6262
lint.extend-select = [
63-
# "A",# See: https://pypi.org/project/flake8-builtins
64-
"B",# See: https://pypi.org/project/flake8-bugbear
65-
"C4",# See: https://pypi.org/project/flake8-comprehensions
66-
"TCH004",# See: https://docs.astral.sh/ruff/rules/runtime-import-in-type-checking-block/
63+
# "A", # See: https://pypi.org/project/flake8-builtins
64+
"B",# See: https://pypi.org/project/flake8-bugbear
65+
"C4",# See: https://pypi.org/project/flake8-comprehensions
66+
"TC004",# See: https://docs.astral.sh/ruff/rules/runtime-import-in-type-checking-block/
6767
]
6868
lint.ignore = [
69-
"E203",# Whitespace before ':'
70-
"E731",# Do not assign a `lambda` expression, use a `def`
69+
# If it becomes necessary to ignore any rules, list them here.
7170
]
72-
lint.ignore-init-module-imports =true
7371
lint.unfixable = [
7472
"F401",# Module imported but unused
7573
]

‎requirements-dev.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
-r requirements.txt
2-
-r test-requirements.txt
3-
4-
# For additional local testing/linting - to be added elsewhere eventually.
5-
ruff
6-
shellcheck
7-
pytest-icdiff
8-
# pytest-profiling
1+
-r requirements.txt
2+
-r test-requirements.txt
3+
4+
# For additional local testing/linting - to be added elsewhere eventually.
5+
ruff>=0.8
6+
shellcheck
7+
pytest-icdiff
8+
# pytest-profiling

‎test/test_fun.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ def test_tree_traversal(self):
243243
B_old=self.rorepo.tree("1f66cfbbce58b4b552b041707a12d437cc5f400a")# old base tree
244244

245245
# Two very different trees.
246+
246247
entries=traverse_trees_recursive(odb, [B_old.binsha,H.binsha],"")
247248
self._assert_tree_entries(entries,2)
248249

@@ -251,7 +252,10 @@ def test_tree_traversal(self):
251252
self._assert_tree_entries(oentries,2)
252253

253254
# Single tree.
254-
is_no_tree=lambdai,d:i.type!="tree"
255+
256+
defis_no_tree(i,_d):
257+
returni.type!="tree"
258+
255259
entries=traverse_trees_recursive(odb, [B.binsha],"")
256260
assertlen(entries)==len(list(B.traverse(predicate=is_no_tree)))
257261
self._assert_tree_entries(entries,1)

‎test/test_index.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,10 @@ def test_index_file_from_tree(self, rw_repo):
330330
assertlen([eforeinthree_way_index.entries.values()ife.stage!=0])
331331

332332
# ITERATE BLOBS
333-
merge_required=lambdat:t[0]!=0
333+
334+
defmerge_required(t):
335+
returnt[0]!=0
336+
334337
merge_blobs=list(three_way_index.iter_blobs(merge_required))
335338
assertmerge_blobs
336339
assertmerge_blobs[0][0]in (1,2,3)

‎test/test_tree.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,18 @@ def test_traverse(self):
126126
assertlen(list(root))==len(list(root.traverse(depth=1)))
127127

128128
# Only choose trees.
129-
trees_only=lambdai,d:i.type=="tree"
129+
130+
deftrees_only(i,_d):
131+
returni.type=="tree"
132+
130133
trees=list(root.traverse(predicate=trees_only))
131134
assertlen(trees)==len([iforiinroot.traverse()iftrees_only(i,0)])
132135

133136
# Test prune.
134-
lib_folder=lambdat,d:t.path=="lib"
137+
138+
deflib_folder(t,_d):
139+
returnt.path=="lib"
140+
135141
pruned_trees=list(root.traverse(predicate=trees_only,prune=lib_folder))
136142
assertlen(pruned_trees)<len(trees)
137143

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp