Skip to content

Commit 55fd173

Browse files
Harmon758Byron
authored andcommitted
Remove and replace compat.text_type
1 parent 768b9ff commit 55fd173

File tree

5 files changed

+8
-13
lines changed

5 files changed

+8
-13
lines changed

git/compat.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414

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

git/objects/commit.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
parse_actor_and_date,
2525
from_timestamp,
2626
)
27-
from git.compat import text_type
2827

2928
from time import (
3029
time,
@@ -436,7 +435,7 @@ def _serialize(self, stream):
436435
write(b"\n")
437436

438437
# write plain bytes, be sure its encoded according to our encoding
439-
if isinstance(self.message, text_type):
438+
if isinstance(self.message, str):
440439
write(self.message.encode(self.encoding))
441440
else:
442441
write(self.message)

git/objects/fun.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
from stat import S_ISDIR
33
from git.compat import (
44
safe_decode,
5-
defenc,
6-
text_type
5+
defenc
76
)
87

98
__all__ = ('tree_to_stream', 'tree_entries_from_data', 'traverse_trees_recursive',
@@ -33,7 +32,7 @@ def tree_to_stream(entries, write):
3332
# hence we must convert to an utf8 string for it to work properly.
3433
# According to my tests, this is exactly what git does, that is it just
3534
# takes the input literally, which appears to be utf8 on linux.
36-
if isinstance(name, text_type):
35+
if isinstance(name, str):
3736
name = name.encode(defenc)
3837
write(b''.join((mode_str, b' ', name, b'\0', binsha)))
3938
# END for each item

git/repo/base.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
handle_process_output
1616
)
1717
from git.compat import (
18-
text_type,
1918
defenc,
2019
safe_decode,
2120
is_win,
@@ -476,7 +475,7 @@ def commit(self, rev=None):
476475
:return: ``git.Commit``"""
477476
if rev is None:
478477
return self.head.commit
479-
return self.rev_parse(text_type(rev) + "^0")
478+
return self.rev_parse(str(rev) + "^0")
480479

481480
def iter_trees(self, *args, **kwargs):
482481
""":return: Iterator yielding Tree objects
@@ -498,7 +497,7 @@ def tree(self, rev=None):
498497
operations might have unexpected results."""
499498
if rev is None:
500499
return self.head.commit.tree
501-
return self.rev_parse(text_type(rev) + "^{tree}")
500+
return self.rev_parse(str(rev) + "^{tree}")
502501

503502
def iter_commits(self, rev=None, paths='', **kwargs):
504503
"""A list of Commit objects representing the history of a given ref/commit

git/test/test_commit.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
Actor,
1818
)
1919
from git import Repo
20-
from git.compat import text_type
2120
from git.objects.util import tzoffset, utc
2221
from git.repo.fun import touch
2322
from git.test.lib import (
@@ -142,7 +141,7 @@ def test_unicode_actor(self):
142141
self.assertEqual(len(name), 9)
143142
special = Actor._from_string(u"%s <something@this.com>" % name)
144143
self.assertEqual(special.name, name)
145-
assert isinstance(special.name, text_type)
144+
assert isinstance(special.name, str)
146145

147146
def test_traversal(self):
148147
start = self.rorepo.commit("a4d06724202afccd2b5c54f81bcf2bf26dea7fff")
@@ -286,8 +285,8 @@ def test_serialization_unicode_support(self):
286285
# create a commit with unicode in the message, and the author's name
287286
# Verify its serialization and deserialization
288287
cmt = self.rorepo.commit('0.1.6')
289-
assert isinstance(cmt.message, text_type) # it automatically decodes it as such
290-
assert isinstance(cmt.author.name, text_type) # same here
288+
assert isinstance(cmt.message, str) # it automatically decodes it as such
289+
assert isinstance(cmt.author.name, str) # same here
291290

292291
cmt.message = u"üäêèß"
293292
self.assertEqual(len(cmt.message), 5)

0 commit comments

Comments
 (0)