Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a5fc1d8

Browse files
committed
Improve consistency of "END" comments
In the git module (including modules it contains). This does not add any new "# end" or "# END" comments. Instead, it improves the consistency and clarity of existing ones by converting each "# end" comment to "# END" (since capitalization was not used systematically to indicate nesting level or other semantic information, and capitalizing "END" makes clear the nature of the comment), and by adding some information to a few of the comments. This also removes end comments that did not provide information or significant visual indication that a "section" was ending, or where the visual indication they provided was at least as well provided by replacing them with a blank line. However, it does *not* attempt to apply this change everywhere it might be applicable.
1 parent 8d3efc5 commit a5fc1d8

File tree

13 files changed

+64
-70
lines changed

13 files changed

+64
-70
lines changed

git/cmd.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -979,7 +979,7 @@ def execute(
979979
else:
980980
cmd_not_found_exception = FileNotFoundError # NOQA # exists, flake8 unknown @UndefinedVariable
981981
maybe_patch_caller_env = contextlib.nullcontext()
982-
# end handle
982+
# END handle
983983

984984
stdout_sink = PIPE if with_stdout else getattr(subprocess, "DEVNULL", None) or open(os.devnull, "wb")
985985
if shell is None:
@@ -1048,7 +1048,7 @@ def kill_process(pid: int) -> None:
10481048
pass
10491049
return
10501050

1051-
# end
1051+
# END def kill_process
10521052

10531053
if kill_after_timeout is not None:
10541054
kill_check = threading.Event()
@@ -1100,7 +1100,7 @@ def kill_process(pid: int) -> None:
11001100
def as_text(stdout_value: Union[bytes, str]) -> str:
11011101
return not output_stream and safe_decode(stdout_value) or "<OUTPUT_STREAM>"
11021102

1103-
# end
1103+
# END def as_text
11041104

11051105
if stderr_value:
11061106
log.info(
@@ -1304,9 +1304,9 @@ def _call_process(
13041304
"Couldn't find argument '%s' in args %s to insert cmd options after"
13051305
% (insert_after_this_arg, str(ext_args))
13061306
) from err
1307-
# end handle error
1307+
# END handle error
13081308
args_list = ext_args[: index + 1] + opt_args + ext_args[index + 1 :]
1309-
# end handle opts_kwargs
1309+
# END handle opts_kwargs
13101310

13111311
call = [self.GIT_PYTHON_GIT_EXECUTABLE]
13121312

git/config.py

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,11 @@ def _read(self, fp: Union[BufferedReader, IO[bytes]], fpname: str) -> None:
446446
def string_decode(v: str) -> str:
447447
if v[-1] == "\\":
448448
v = v[:-1]
449-
# end cut trailing escapes to prevent decode error
449+
# END cut trailing escapes to prevent decode error
450450

451451
return v.encode(defenc).decode("unicode_escape")
452-
# end
453452

454-
# end
453+
# END def string_decode
455454

456455
while True:
457456
# We assume to read binary!
@@ -496,12 +495,12 @@ def string_decode(v: str) -> str:
496495
optval = optval.strip()
497496
if optval == '""':
498497
optval = ""
499-
# end handle empty string
498+
# END handle empty string
500499
optname = self.optionxform(optname.rstrip())
501500
if len(optval) > 1 and optval[0] == '"' and optval[-1] != '"':
502501
is_multi_line = True
503502
optval = string_decode(optval[1:])
504-
# end handle multi-line
503+
# END handle multi-line
505504
# Preserves multiple values for duplicate optnames.
506505
cursect.add(optname, optval)
507506
else:
@@ -516,7 +515,7 @@ def string_decode(v: str) -> str:
516515
if line.endswith('"'):
517516
is_multi_line = False
518517
line = line[:-1]
519-
# end handle quotations
518+
# END handle quotations
520519
optval = cursect.getlast(optname)
521520
cursect.setlast(optname, optval + string_decode(line))
522521
# END parse section or option
@@ -600,7 +599,7 @@ def read(self) -> None: # type: ignore[override]
600599
files_to_read = [self._file_or_files]
601600
else: # for lists or tuples
602601
files_to_read = list(self._file_or_files)
603-
# end ensure we have a copy of the paths to handle
602+
# END ensure we have a copy of the paths to handle
604603

605604
seen = set(files_to_read)
606605
num_read_include_files = 0
@@ -631,27 +630,26 @@ def read(self) -> None: # type: ignore[override]
631630
if not osp.isabs(include_path):
632631
if not file_ok:
633632
continue
634-
# end ignore relative paths if we don't know the configuration file path
633+
# END ignore relative paths if we don't know the configuration file path
635634
file_path = cast(PathLike, file_path)
636635
assert osp.isabs(file_path), "Need absolute paths to be sure our cycle checks will work"
637636
include_path = osp.join(osp.dirname(file_path), include_path)
638-
# end make include path absolute
637+
# END make include path absolute
639638
include_path = osp.normpath(include_path)
640639
if include_path in seen or not os.access(include_path, os.R_OK):
641640
continue
642641
seen.add(include_path)
643642
# Insert included file to the top to be considered first.
644643
files_to_read.insert(0, include_path)
645644
num_read_include_files += 1
646-
# each include path in configuration file
647-
# end handle includes
645+
# END each include path in configuration file
646+
# END handle includes
648647
# END for each file object to read
649648

650649
# If there was no file included, we can safely write back (potentially) the
651650
# configuration file without altering its meaning.
652651
if num_read_include_files == 0:
653652
self._merge_includes = False
654-
# end
655653

656654
def _write(self, fp: IO) -> None:
657655
"""Write an .ini-format representation of the configuration state in
@@ -714,15 +712,15 @@ def write(self) -> None:
714712
"Cannot write back if there is not exactly a single file to write to, have %i files"
715713
% len(self._file_or_files)
716714
)
717-
# end assert multiple files
715+
# END assert multiple files
718716

719717
if self._has_includes():
720718
log.debug(
721719
"Skipping write-back of configuration file as include files were merged in."
722720
+ "Set merge_includes=False to prevent this."
723721
)
724722
return None
725-
# end
723+
# END stop if we have include files
726724

727725
fp = self._file_or_files
728726

@@ -904,7 +902,7 @@ def rename_section(self, section: str, new_name: str) -> "GitConfigParser":
904902
new_section = self._sections[new_name]
905903
for k, vs in self.items_all(section):
906904
new_section.setall(k, vs)
907-
# end for each value to copy
905+
# END for each value to copy
908906

909907
# This call writes back the changes, which is why we don't have the respective decorator.
910908
self.remove_section(section)

git/diff.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def __str__(self) -> str:
442442
msg += self.diff.decode(defenc) if isinstance(self.diff, bytes) else self.diff
443443
except UnicodeDecodeError:
444444
msg += "OMITTED BINARY DATA"
445-
# end handle encoding
445+
# END handle encoding
446446
msg += "\n---"
447447
# END diff info
448448

@@ -543,7 +543,7 @@ def _index_from_patch_format(cls, repo: "Repo", proc: Union["Popen", "Git.AutoIn
543543
# and then retro-actively assign it to our index.
544544
if previous_header is not None:
545545
index[-1].diff = text[previous_header.end() : _header.start()]
546-
# end assign actual diff
546+
# END assign actual diff
547547

548548
# Make sure the mode is set if the path is set. Otherwise the resulting blob is invalid.
549549
# We just use the one mode we should have parsed.
@@ -571,10 +571,10 @@ def _index_from_patch_format(cls, repo: "Repo", proc: Union["Popen", "Git.AutoIn
571571

572572
previous_header = _header
573573
header = _header
574-
# end for each header we parse
574+
# END for each header we parse
575575
if index and header:
576576
index[-1].diff = text[header.end() :]
577-
# end assign last diff
577+
# END assign last diff
578578

579579
return index
580580

git/index/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def raise_exc(e: Exception) -> NoReturn:
406406
if S_ISLNK(st.st_mode):
407407
yield abs_path.replace(rs, "")
408408
continue
409-
# end check symlink
409+
# END check symlink
410410

411411
# If the path is not already pointing to an existing file, resolve globs if possible.
412412
if not os.path.exists(abs_path) and ("?" in abs_path or "*" in abs_path or "[" in abs_path):
@@ -689,7 +689,7 @@ def _entries_for_paths(
689689
gitrelative_path = path
690690
if self.repo.working_tree_dir:
691691
abspath = osp.join(self.repo.working_tree_dir, gitrelative_path)
692-
# end obtain relative and absolute paths
692+
# END obtain relative and absolute paths
693693

694694
blob = Blob(
695695
self.repo,
@@ -867,7 +867,7 @@ def handle_null_entries(self: "IndexFile") -> None:
867867
)
868868
# END for each entry index
869869

870-
# end closure
870+
# END closure
871871
handle_null_entries(self)
872872
# END null_entry handling
873873

git/index/fun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def run_commit_hook(name: str, index: "IndexFile", *args: str) -> None:
123123
stdout = force_text(stdout, defenc)
124124
stderr = force_text(stderr, defenc)
125125
raise HookExecutionError(hp, process.returncode, stderr, stdout)
126-
# end handle return code
126+
# END handle return code
127127

128128

129129
def stat_mode_to_index_mode(mode: int) -> int:

git/objects/commit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,7 @@ def create_from_tree(
553553
for p in parent_commits:
554554
if not isinstance(p, cls):
555555
raise ValueError(f"Parent commit '{p!r}' must be of type {cls}")
556-
# end check parent commit types
556+
# END check parent commit types
557557
# END if parent commits are unset
558558

559559
# Retrieve all additional information, create a commit object, and serialize it.
@@ -730,7 +730,7 @@ def _deserialize(self, stream: BytesIO) -> "Commit":
730730
next_line = readline()
731731
while next_line.startswith(b" "):
732732
next_line = readline()
733-
# end skip mergetags
733+
# END skip mergetags
734734

735735
# Now we can have the encoding line, or an empty line followed by the optional message.
736736
self.encoding = self.default_encoding
@@ -754,7 +754,7 @@ def _deserialize(self, stream: BytesIO) -> "Commit":
754754
is_next_header = True
755755
break
756756
sig += sigbuf[1:]
757-
# end read all signature
757+
# END read all signature
758758
self.gpgsig = sig.rstrip(b"\n").decode(self.encoding, "ignore")
759759
if is_next_header:
760760
continue

0 commit comments

Comments
 (0)