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

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

‎git/test/test_commit.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
Actor,
1818
)
1919
fromgitimportRepo
20-
fromgit.compatimport (
21-
string_types,
22-
text_type
23-
)
20+
fromgit.compatimporttext_type
2421
fromgit.objects.utilimporttzoffset,utc
2522
fromgit.repo.funimporttouch
2623
fromgit.test.libimport (
@@ -276,7 +273,7 @@ def test_iter_parents(self):
276273

277274
deftest_name_rev(self):
278275
name_rev=self.rorepo.head.commit.name_rev
279-
assertisinstance(name_rev,string_types)
276+
assertisinstance(name_rev,str)
280277

281278
@with_rw_repo('HEAD',bare=True)
282279
deftest_serialization(self,rwrepo):

‎git/test/test_config.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
fromgitimport (
1111
GitConfigParser
1212
)
13-
fromgit.compatimportstring_types
1413
fromgit.configimport_OMD,cp
1514
fromgit.test.libimport (
1615
TestCase,
@@ -157,7 +156,7 @@ def test_base(self):
157156
num_options+=1
158157
val=r_config.get(section,option)
159158
val_typed=r_config.get_value(section,option)
160-
assertisinstance(val_typed, (bool,int,float,)+string_types)
159+
assertisinstance(val_typed, (bool,int,float,str))
161160
assertval
162161
assert"\n"notinoption
163162
assert"\n"notinval

‎git/test/test_index.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
GitCommandError,
2626
CheckoutError,
2727
)
28-
fromgit.compatimportstring_types,is_win
28+
fromgit.compatimportis_win
2929
fromgit.excimport (
3030
HookExecutionError,
3131
InvalidGitRepositoryError
@@ -388,7 +388,7 @@ def test_index_file_diffing(self, rw_repo):
388388
self.assertEqual(len(e.failed_files),1)
389389
self.assertEqual(e.failed_files[0],osp.basename(test_file))
390390
self.assertEqual(len(e.failed_files),len(e.failed_reasons))
391-
self.assertIsInstance(e.failed_reasons[0],string_types)
391+
self.assertIsInstance(e.failed_reasons[0],str)
392392
self.assertEqual(len(e.valid_files),0)
393393
withopen(test_file,'rb')asfd:
394394
s=fd.read()

‎git/test/test_remote.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
GitCommandError
2323
)
2424
fromgit.cmdimportGit
25-
fromgit.compatimportstring_types
2625
fromgit.test.libimport (
2726
TestBase,
2827
with_rw_repo,
@@ -116,7 +115,7 @@ def _do_test_fetch_result(self, results, remote):
116115
self.assertGreater(len(results),0)
117116
self.assertIsInstance(results[0],FetchInfo)
118117
forinfoinresults:
119-
self.assertIsInstance(info.note,string_types)
118+
self.assertIsInstance(info.note,str)
120119
ifisinstance(info.ref,Reference):
121120
self.assertTrue(info.flags)
122121
# END reference type flags handling
@@ -133,7 +132,7 @@ def _do_test_push_result(self, results, remote):
133132
self.assertIsInstance(results[0],PushInfo)
134133
forinfoinresults:
135134
self.assertTrue(info.flags)
136-
self.assertIsInstance(info.summary,string_types)
135+
self.assertIsInstance(info.summary,str)
137136
ifinfo.old_commitisnotNone:
138137
self.assertIsInstance(info.old_commit,Commit)
139138
ifinfo.flags&info.ERROR:

‎git/test/test_repo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
)
3939
fromgit.compatimport (
4040
is_win,
41-
string_types,
4241
win_encode,
4342
)
4443
fromgit.excimport (
@@ -441,7 +440,7 @@ def test_should_display_blame_information(self, git):
441440
# test the 'lines per commit' entries
442441
tlist=b[0][1]
443442
assert_true(tlist)
444-
assert_true(isinstance(tlist[0],string_types))
443+
assert_true(isinstance(tlist[0],str))
445444
assert_true(len(tlist)<sum(len(t)fortintlist))# test for single-char bug
446445

447446
# BINARY BLAME

‎git/test/test_submodule.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
importgit
1010
fromgit.cmdimportGit
11-
fromgit.compatimportstring_types,is_win
11+
fromgit.compatimportis_win
1212
fromgit.excimport (
1313
InvalidGitRepositoryError,
1414
RepositoryDirtyError
@@ -79,7 +79,7 @@ def _do_base_tests(self, rwrepo):
7979
self.failUnlessRaises(InvalidGitRepositoryError,getattr,sm,'branch')
8080

8181
# branch_path works, as its just a string
82-
assertisinstance(sm.branch_path,string_types)
82+
assertisinstance(sm.branch_path,str)
8383

8484
# some commits earlier we still have a submodule, but its at a different commit
8585
smold=next(Submodule.iter_items(rwrepo,self.k_subm_changed))

‎git/test/test_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
importddt
1414

1515
fromgit.cmdimportdashify
16-
fromgit.compatimportstring_types,is_win
16+
fromgit.compatimportis_win
1717
fromgit.objects.utilimport (
1818
altz_to_utctz_str,
1919
utctz_to_altz,
@@ -187,7 +187,7 @@ def assert_rval(rval, veri_time, offset=0):
187187

188188
# now that we are here, test our conversion functions as well
189189
utctz=altz_to_utctz_str(offset)
190-
self.assertIsInstance(utctz,string_types)
190+
self.assertIsInstance(utctz,str)
191191
self.assertEqual(utctz_to_altz(verify_utctz(utctz)),offset)
192192
# END assert rval utility
193193

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp