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

Appearance settings

Commit 768b9ff

Browse filesBrowse files
Harmon758Byron
authored andcommitted
Remove and replace compat.string_types
1 parent 5d22d57 commit 768b9ff
Copy full SHA for 768b9ff

17 files changed

+31
-49
lines changed

‎git/cmd.py

Copy file name to clipboardExpand all lines: git/cmd.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
from textwrap import dedent
2222

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

10441043
if not refstr.endswith("\n"):

‎git/compat.py

Copy file name to clipboardExpand all lines: git/compat.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

1515
from gitdb.utils.encoding import (
16-
string_types, # @UnusedImport
1716
text_type, # @UnusedImport
1817
force_bytes, # @UnusedImport
1918
force_text # @UnusedImport

‎git/config.py

Copy file name to clipboardExpand all lines: git/config.py
+3-4Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from collections import OrderedDict
1717

1818
from git.compat import (
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-
if not isinstance(self._file_or_files, string_types):
304+
if not isinstance(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
if is_file_lock:
583582
self._lock._obtain_lock()
584583
if not hasattr(fp, "seek"):
@@ -670,7 +669,7 @@ def _string_to_value(self, valuestr):
670669
if vl == 'true':
671670
return True
672671

673-
if not isinstance(valuestr, string_types):
672+
if not isinstance(valuestr, str):
674673
raise TypeError(
675674
"Invalid value type: only int, long, float and str are allowed",
676675
valuestr)

‎git/exc.py

Copy file name to clipboardExpand all lines: git/exc.py
+2-2Lines 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
from gitdb.exc import * # NOQA @UnusedWildImport skipcq: PYL-W0401, PYL-W0614
9-
from git.compat import safe_decode, string_types
9+
from git.compat import safe_decode
1010

1111

1212
class GitError(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'" % s if isinstance(status, string_types) else s
53+
status = u"'%s'" % s if isinstance(status, str) else s
5454

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

‎git/index/base.py

Copy file name to clipboardExpand all lines: git/index/base.py
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import tempfile
1212

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

573572
for item in items:
574-
if isinstance(item, string_types):
573+
if isinstance(item, str):
575574
paths.append(self._to_relative_path(item))
576575
elif isinstance(item, (Blob, Submodule)):
577576
entries.append(BaseIndexEntry.from_blob(item))
@@ -808,7 +807,7 @@ def _items_to_rela_paths(self, items):
808807
for item in items:
809808
if isinstance(item, (BaseIndexEntry, (Blob, Submodule))):
810809
paths.append(self._to_relative_path(item.path))
811-
elif isinstance(item, string_types):
810+
elif isinstance(item, str):
812811
paths.append(self._to_relative_path(item))
813812
else:
814813
raise TypeError("Invalid item type: %r" % item)
@@ -1087,7 +1086,7 @@ def handle_stderr(proc, iter_checked_out_files):
10871086
handle_stderr(proc, rval_iter)
10881087
return rval_iter
10891088
else:
1090-
if isinstance(paths, string_types):
1089+
if isinstance(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-
if isinstance(other, string_types):
1226+
if isinstance(other, str):
12281227
other = self.repo.rev_parse(other)
12291228
# END object conversion
12301229

‎git/objects/submodule/base.py

Copy file name to clipboardExpand all lines: git/objects/submodule/base.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import git
1010
from git.cmd import Git
1111
from git.compat import (
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
if url is not None:
111110
self._url = url
112111
if branch_path is not None:
113-
assert isinstance(branch_path, string_types)
112+
assert isinstance(branch_path, str)
114113
self._branch_path = branch_path
115114
if name is not None:
116115
self._name = name

‎git/objects/tree.py

Copy file name to clipboardExpand all lines: git/objects/tree.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from .base import IndexObject
1212
from .blob import Blob
1313
from .submodule.base import Submodule
14-
from git.compat import string_types
1514

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

293-
if isinstance(item, string_types):
292+
if isinstance(item, str):
294293
# compatibility
295294
return self.join(item)
296295
# END index is basestring

‎git/refs/log.py

Copy file name to clipboardExpand all lines: git/refs/log.py
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import re
22
import time
33

4-
from git.compat import (
5-
string_types,
6-
defenc
7-
)
4+
from git.compat import defenc
85
from git.objects.util import (
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-
if isinstance(stream, string_types):
185+
if isinstance(stream, str):
189186
stream = file_contents_ro_filepath(stream)
190187
# END handle stream type
191188
while True:

‎git/refs/symbolic.py

Copy file name to clipboardExpand all lines: git/refs/symbolic.py
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import os
22

3-
from git.compat import (
4-
string_types,
5-
defenc
6-
)
3+
from git.compat import defenc
74
from git.objects import Object, Commit
85
from git.util import (
96
join_path,
@@ -300,7 +297,7 @@ def set_reference(self, ref, logmsg=None):
300297
elif isinstance(ref, Object):
301298
obj = ref
302299
write_value = ref.hexsha
303-
elif isinstance(ref, string_types):
300+
elif isinstance(ref, str):
304301
try:
305302
obj = self.repo.rev_parse(ref + "^{}") # optionally deref tags
306303
write_value = obj.hexsha

‎git/test/lib/helper.py

Copy file name to clipboardExpand all lines: git/test/lib/helper.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import time
1818
import unittest
1919

20-
from git.compat import string_types, is_win
20+
from git.compat import is_win
2121
from git.util import rmtree, cwd
2222
import gitdb
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-
assert isinstance(working_tree_ref, string_types), "Decorator requires ref name for working tree checkout"
120+
assert isinstance(working_tree_ref, str), "Decorator requires ref name for working tree checkout"
121121

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

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

253253
def argument_passer(func):
254254

‎git/test/test_commit.py

Copy file name to clipboardExpand all lines: git/test/test_commit.py
+2-5Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
Actor,
1818
)
1919
from git import Repo
20-
from git.compat import (
21-
string_types,
22-
text_type
23-
)
20+
from git.compat import text_type
2421
from git.objects.util import tzoffset, utc
2522
from git.repo.fun import touch
2623
from git.test.lib import (
@@ -276,7 +273,7 @@ def test_iter_parents(self):
276273

277274
def test_name_rev(self):
278275
name_rev = self.rorepo.head.commit.name_rev
279-
assert isinstance(name_rev, string_types)
276+
assert isinstance(name_rev, str)
280277

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

‎git/test/test_config.py

Copy file name to clipboardExpand all lines: git/test/test_config.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from git import (
1111
GitConfigParser
1212
)
13-
from git.compat import string_types
1413
from git.config import _OMD, cp
1514
from git.test.lib import (
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-
assert isinstance(val_typed, (bool, int, float, ) + string_types)
159+
assert isinstance(val_typed, (bool, int, float, str))
161160
assert val
162161
assert "\n" not in option
163162
assert "\n" not in val

‎git/test/test_index.py

Copy file name to clipboardExpand all lines: git/test/test_index.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
GitCommandError,
2626
CheckoutError,
2727
)
28-
from git.compat import string_types, is_win
28+
from git.compat import is_win
2929
from git.exc import (
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
with open(test_file, 'rb') as fd:
394394
s = fd.read()

‎git/test/test_remote.py

Copy file name to clipboardExpand all lines: git/test/test_remote.py
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
GitCommandError
2323
)
2424
from git.cmd import Git
25-
from git.compat import string_types
2625
from git.test.lib import (
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
for info in results:
119-
self.assertIsInstance(info.note, string_types)
118+
self.assertIsInstance(info.note, str)
120119
if isinstance(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
for info in results:
135134
self.assertTrue(info.flags)
136-
self.assertIsInstance(info.summary, string_types)
135+
self.assertIsInstance(info.summary, str)
137136
if info.old_commit is not None:
138137
self.assertIsInstance(info.old_commit, Commit)
139138
if info.flags & info.ERROR:

‎git/test/test_repo.py

Copy file name to clipboardExpand all lines: git/test/test_repo.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
)
3939
from git.compat import (
4040
is_win,
41-
string_types,
4241
win_encode,
4342
)
4443
from git.exc import (
@@ -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) for t in tlist)) # test for single-char bug
446445

447446
# BINARY BLAME

‎git/test/test_submodule.py

Copy file name to clipboardExpand all lines: git/test/test_submodule.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import git
1010
from git.cmd import Git
11-
from git.compat import string_types, is_win
11+
from git.compat import is_win
1212
from git.exc import (
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-
assert isinstance(sm.branch_path, string_types)
82+
assert isinstance(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

Copy file name to clipboardExpand all lines: git/test/test_util.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import ddt
1414

1515
from git.cmd import dashify
16-
from git.compat import string_types, is_win
16+
from git.compat import is_win
1717
from git.objects.util import (
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.