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

Commitffcbf07

Browse files
committed
Put all regex patterns in r-strings
This improves consistency, because most were already. For a few itallows backslashes to removed, improving readability. Even for theothers, some editors will highlight them as regular expressions nowthat they are raw string literals.
1 parent7dd2095 commitffcbf07

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

‎git/cmd.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ class Git(LazyMixin):
264264

265265
_excluded_= ("cat_file_all","cat_file_header","_version_info")
266266

267-
re_unsafe_protocol=re.compile("(.+)::.+")
267+
re_unsafe_protocol=re.compile(r"(.+)::.+")
268268

269269
def__getstate__(self)->Dict[str,Any]:
270270
returnslots_to_dict(self,exclude=self._excluded_)

‎git/diff.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
# Special object to compare against the empty tree in diffs
5454
NULL_TREE=object()
5555

56-
_octal_byte_re=re.compile(b"\\\\([0-9]{3})")
56+
_octal_byte_re=re.compile(rb"\\([0-9]{3})")
5757

5858

5959
def_octal_repl(matchobj:Match)->bytes:

‎git/refs/log.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class RefLogEntry(Tuple[str, str, Actor, Tuple[int, int], str]):
4141

4242
"""Named tuple allowing easy access to the revlog data fields"""
4343

44-
_re_hexsha_only=re.compile("^[0-9A-Fa-f]{40}$")
44+
_re_hexsha_only=re.compile(r"^[0-9A-Fa-f]{40}$")
4545
__slots__= ()
4646

4747
def__repr__(self)->str:

‎git/repo/base.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ class Repo(object):
131131

132132
# precompiled regex
133133
re_whitespace=re.compile(r"\s+")
134-
re_hexsha_only=re.compile("^[0-9A-Fa-f]{40}$")
135-
re_hexsha_shortened=re.compile("^[0-9A-Fa-f]{4,40}$")
134+
re_hexsha_only=re.compile(r"^[0-9A-Fa-f]{40}$")
135+
re_hexsha_shortened=re.compile(r"^[0-9A-Fa-f]{4,40}$")
136136
re_envvars=re.compile(r"(\$(\{\s?)?[a-zA-Z_]\w*(\}\s?)?|%\s?[a-zA-Z_]\w*\s?%)")
137137
re_author_committer_start=re.compile(r"^(author|committer)")
138138
re_tab_full_line=re.compile(r"^\t(.*)$")

‎test/test_exc.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def test_CommandError_unicode(self, case):
102102

103103
ifsubsisnotNone:
104104
# Substrings (must) already contain opening `'`.
105-
subs="(?<!')%s(?!')"%re.escape(subs)
105+
subs=r"(?<!')%s(?!')"%re.escape(subs)
106106
self.assertRegex(s,subs)
107107

108108
ifnotstream:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2026 Movatter.jp