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

Commit768b9ff

Browse files
Harmon758Byron
authored andcommitted
Remove and replace compat.string_types
1 parent5d22d57 commit768b9ff

File tree

17 files changed

+31
-49
lines changed

17 files changed

+31
-49
lines changed

‎git/cmd.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
fromtextwrapimportdedent
2222

2323
fromgit.compatimport (
24-
string_types,
2524
defenc,
2625
force_bytes,
2726
safe_decode,
@@ -1038,7 +1037,7 @@ def _prepare_ref(self, ref):
10381037
ifisinstance(ref,bytes):
10391038
# Assume 40 bytes hexsha - bin-to-ascii for some reason returns bytes, not text
10401039
refstr=ref.decode('ascii')
1041-
elifnotisinstance(ref,string_types):
1040+
elifnotisinstance(ref,str):
10421041
refstr=str(ref)# could be ref-object
10431042

10441043
ifnotrefstr.endswith("\n"):

‎git/compat.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
fromgitdb.utils.encodingimport (
16-
string_types,# @UnusedImport
1716
text_type,# @UnusedImport
1817
force_bytes,# @UnusedImport
1918
force_text# @UnusedImport

‎git/config.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
fromcollectionsimportOrderedDict
1717

1818
fromgit.compatimport (
19-
string_types,
2019
defenc,
2120
force_text,
2221
with_metaclass,
@@ -302,7 +301,7 @@ def _acquire_lock(self):
302301
# END single file check
303302

304303
file_or_files=self._file_or_files
305-
ifnotisinstance(self._file_or_files,string_types):
304+
ifnotisinstance(self._file_or_files,str):
306305
file_or_files=self._file_or_files.name
307306
# END get filename from handle/stream
308307
# initialize lock base - we want to write
@@ -578,7 +577,7 @@ def write(self):
578577
fp=self._file_or_files
579578

580579
# we have a physical file on disk, so get a lock
581-
is_file_lock=isinstance(fp,string_types+ (IOBase,))
580+
is_file_lock=isinstance(fp,(str,IOBase))
582581
ifis_file_lock:
583582
self._lock._obtain_lock()
584583
ifnothasattr(fp,"seek"):
@@ -670,7 +669,7 @@ def _string_to_value(self, valuestr):
670669
ifvl=='true':
671670
returnTrue
672671

673-
ifnotisinstance(valuestr,string_types):
672+
ifnotisinstance(valuestr,str):
674673
raiseTypeError(
675674
"Invalid value type: only int, long, float and str are allowed",
676675
valuestr)

‎git/exc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
""" Module containing all exceptions thrown throughout the git package, """
77

88
fromgitdb.excimport*# NOQA @UnusedWildImport skipcq: PYL-W0401, PYL-W0614
9-
fromgit.compatimportsafe_decode,string_types
9+
fromgit.compatimportsafe_decode
1010

1111

1212
classGitError(Exception):
@@ -50,7 +50,7 @@ def __init__(self, command, status=None, stderr=None, stdout=None):
5050
status=u'exit code(%s)'%int(status)
5151
except (ValueError,TypeError):
5252
s=safe_decode(str(status))
53-
status=u"'%s'"%sifisinstance(status,string_types)elses
53+
status=u"'%s'"%sifisinstance(status,str)elses
5454

5555
self._cmd=safe_decode(command[0])
5656
self._cmdline=u' '.join(safe_decode(i)foriincommand)

‎git/index/base.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
importtempfile
1212

1313
fromgit.compatimport (
14-
string_types,
1514
force_bytes,
1615
defenc,
1716
)
@@ -571,7 +570,7 @@ def _preprocess_add_items(self, items):
571570
items= [items]
572571

573572
foriteminitems:
574-
ifisinstance(item,string_types):
573+
ifisinstance(item,str):
575574
paths.append(self._to_relative_path(item))
576575
elifisinstance(item, (Blob,Submodule)):
577576
entries.append(BaseIndexEntry.from_blob(item))
@@ -808,7 +807,7 @@ def _items_to_rela_paths(self, items):
808807
foriteminitems:
809808
ifisinstance(item, (BaseIndexEntry, (Blob,Submodule))):
810809
paths.append(self._to_relative_path(item.path))
811-
elifisinstance(item,string_types):
810+
elifisinstance(item,str):
812811
paths.append(self._to_relative_path(item))
813812
else:
814813
raiseTypeError("Invalid item type: %r"%item)
@@ -1087,7 +1086,7 @@ def handle_stderr(proc, iter_checked_out_files):
10871086
handle_stderr(proc,rval_iter)
10881087
returnrval_iter
10891088
else:
1090-
ifisinstance(paths,string_types):
1089+
ifisinstance(paths,str):
10911090
paths= [paths]
10921091

10931092
# make sure we have our entries loaded before we start checkout_index
@@ -1224,7 +1223,7 @@ def diff(self, other=diff.Diffable.Index, paths=None, create_patch=False, **kwar
12241223
# index against anything but None is a reverse diff with the respective
12251224
# item. Handle existing -R flags properly. Transform strings to the object
12261225
# so that we can call diff on it
1227-
ifisinstance(other,string_types):
1226+
ifisinstance(other,str):
12281227
other=self.repo.rev_parse(other)
12291228
# END object conversion
12301229

‎git/objects/submodule/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
importgit
1010
fromgit.cmdimportGit
1111
fromgit.compatimport (
12-
string_types,
1312
defenc,
1413
is_win,
1514
)
@@ -110,7 +109,7 @@ def __init__(self, repo, binsha, mode=None, path=None, name=None, parent_commit=
110109
ifurlisnotNone:
111110
self._url=url
112111
ifbranch_pathisnotNone:
113-
assertisinstance(branch_path,string_types)
112+
assertisinstance(branch_path,str)
114113
self._branch_path=branch_path
115114
ifnameisnotNone:
116115
self._name=name

‎git/objects/tree.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from .baseimportIndexObject
1212
from .blobimportBlob
1313
from .submodule.baseimportSubmodule
14-
fromgit.compatimportstring_types
1514

1615
from .funimport (
1716
tree_entries_from_data,
@@ -290,7 +289,7 @@ def __getitem__(self, item):
290289
info=self._cache[item]
291290
returnself._map_id_to_type[info[1]>>12](self.repo,info[0],info[1],join_path(self.path,info[2]))
292291

293-
ifisinstance(item,string_types):
292+
ifisinstance(item,str):
294293
# compatibility
295294
returnself.join(item)
296295
# END index is basestring

‎git/refs/log.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
importre
22
importtime
33

4-
fromgit.compatimport (
5-
string_types,
6-
defenc
7-
)
4+
fromgit.compatimportdefenc
85
fromgit.objects.utilimport (
96
parse_date,
107
Serializable,
@@ -185,7 +182,7 @@ def iter_entries(cls, stream):
185182
:param stream: file-like object containing the revlog in its native format
186183
or basestring instance pointing to a file to read"""
187184
new_entry=RefLogEntry.from_line
188-
ifisinstance(stream,string_types):
185+
ifisinstance(stream,str):
189186
stream=file_contents_ro_filepath(stream)
190187
# END handle stream type
191188
whileTrue:

‎git/refs/symbolic.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
importos
22

3-
fromgit.compatimport (
4-
string_types,
5-
defenc
6-
)
3+
fromgit.compatimportdefenc
74
fromgit.objectsimportObject,Commit
85
fromgit.utilimport (
96
join_path,
@@ -300,7 +297,7 @@ def set_reference(self, ref, logmsg=None):
300297
elifisinstance(ref,Object):
301298
obj=ref
302299
write_value=ref.hexsha
303-
elifisinstance(ref,string_types):
300+
elifisinstance(ref,str):
304301
try:
305302
obj=self.repo.rev_parse(ref+"^{}")# optionally deref tags
306303
write_value=obj.hexsha

‎git/test/lib/helper.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
importtime
1818
importunittest
1919

20-
fromgit.compatimportstring_types,is_win
20+
fromgit.compatimportis_win
2121
fromgit.utilimportrmtree,cwd
2222
importgitdb
2323

@@ -117,7 +117,7 @@ def with_rw_repo(working_tree_ref, bare=False):
117117
To make working with relative paths easier, the cwd will be set to the working
118118
dir of the repository.
119119
"""
120-
assertisinstance(working_tree_ref,string_types),"Decorator requires ref name for working tree checkout"
120+
assertisinstance(working_tree_ref,str),"Decorator requires ref name for working tree checkout"
121121

122122
defargument_passer(func):
123123
@wraps(func)
@@ -248,7 +248,7 @@ def case(self, rw_repo, rw_daemon_repo)
248248
"""
249249
fromgitimportGit,Remote# To avoid circular deps.
250250

251-
assertisinstance(working_tree_ref,string_types),"Decorator requires ref name for working tree checkout"
251+
assertisinstance(working_tree_ref,str),"Decorator requires ref name for working tree checkout"
252252

253253
defargument_passer(func):
254254

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp