diff --git a/doc/source/conf.py b/doc/source/conf.py index 2df3bbb63..312b61445 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -42,8 +42,8 @@ master_doc = 'index' # General information about the project. -project = u'GitPython' -copyright = u'Copyright (C) 2008, 2009 Michael Trier and contributors, 2010-2015 Sebastian Thiel' +project = 'GitPython' +copyright = 'Copyright (C) 2008, 2009 Michael Trier and contributors, 2010-2015 Sebastian Thiel' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -174,8 +174,8 @@ # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, document class [howto/manual]). latex_documents = [ - ('index', 'GitPython.tex', ur'GitPython Documentation', - ur'Michael Trier', 'manual'), + ('index', 'GitPython.tex', r'GitPython Documentation', + r'Michael Trier', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of diff --git a/git/__init__.py b/git/__init__.py index 8c31e3094..e341ec030 100644 --- a/git/__init__.py +++ b/git/__init__.py @@ -55,5 +55,5 @@ def _init_externals(): #} END imports -__all__ = [name for name, obj in locals().items() +__all__ = [name for name, obj in list(locals().items()) if not (name.startswith('_') or inspect.ismodule(obj))] diff --git a/git/cmd.py b/git/cmd.py index 3637ac9e4..e90bdb1f7 100644 --- a/git/cmd.py +++ b/git/cmd.py @@ -24,7 +24,7 @@ force_bytes, PY3, # just to satisfy flake8 on py3 - unicode, + str, safe_decode, is_posix, is_win, @@ -128,7 +128,7 @@ def slots_to_dict(self, exclude=()): def dict_to_slots_and__excluded_are_none(self, d, excluded=()): - for k, v in d.items(): + for k, v in list(d.items()): setattr(self, k, v) for k in excluded: setattr(self, k, None) @@ -381,7 +381,7 @@ def readlines(self, size=-1): def __iter__(self): return self - def next(self): + def __next__(self): line = self.readline() if not line: raise StopIteration @@ -714,7 +714,7 @@ def update_environment(self, **kwargs): :return: dict that maps environment variables to their old values """ old_env = {} - for key, value in kwargs.items(): + for key, value in list(kwargs.items()): # set value if it is None if value is not None: old_env[key] = self._environment.get(key) @@ -763,8 +763,8 @@ def transform_kwarg(self, name, value, split_single_char_options): def transform_kwargs(self, split_single_char_options=True, **kwargs): """Transforms Python style kwargs into git command line options.""" args = list() - kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0])) - for k, v in kwargs.items(): + kwargs = OrderedDict(sorted(list(kwargs.items()), key=lambda x: x[0])) + for k, v in list(kwargs.items()): if isinstance(v, (list, tuple)): for value in v: args += self.transform_kwarg(k, value, split_single_char_options) @@ -777,7 +777,7 @@ def __unpack_args(cls, arg_list): if not isinstance(arg_list, (list, tuple)): # This is just required for unicode conversion, as subprocess can't handle it # However, in any other case, passing strings (usually utf-8 encoded) is totally fine - if not PY3 and isinstance(arg_list, unicode): + if not PY3 and isinstance(arg_list, str): return [arg_list.encode(defenc)] return [str(arg_list)] @@ -785,7 +785,7 @@ def __unpack_args(cls, arg_list): for arg in arg_list: if isinstance(arg_list, (list, tuple)): outlist.extend(cls.__unpack_args(arg)) - elif not PY3 and isinstance(arg_list, unicode): + elif not PY3 and isinstance(arg_list, str): outlist.append(arg_list.encode(defenc)) # END recursion else: @@ -840,8 +840,8 @@ def _call_process(self, method, *args, **kwargs): :return: Same as ``execute``""" # Handle optional arguments prior to calling transform_kwargs # otherwise these'll end up in args, which is bad. - exec_kwargs = dict((k, v) for k, v in kwargs.items() if k in execute_kwargs) - opts_kwargs = dict((k, v) for k, v in kwargs.items() if k not in execute_kwargs) + exec_kwargs = dict((k, v) for k, v in list(kwargs.items()) if k in execute_kwargs) + opts_kwargs = dict((k, v) for k, v in list(kwargs.items()) if k not in execute_kwargs) insert_after_this_arg = opts_kwargs.pop('insert_kwargs_after', None) diff --git a/git/compat.py b/git/compat.py index b80458576..0130b11b6 100644 --- a/git/compat.py +++ b/git/compat.py @@ -43,10 +43,10 @@ def bchr(n): return bytes([n]) def mviter(d): - return d.values() + return list(d.values()) range = xrange # @ReservedAssignment - unicode = str + str = str binary_type = bytes else: FileType = file # @UndefinedVariable on PY3 @@ -56,17 +56,17 @@ def mviter(d): defenc = 'utf-8' byte_ord = ord bchr = chr - unicode = unicode + str = str binary_type = str range = xrange # @ReservedAssignment def mviter(d): - return d.itervalues() + return iter(d.values()) def safe_decode(s): """Safely decodes a binary string to unicode""" - if isinstance(s, unicode): + if isinstance(s, str): return s elif isinstance(s, bytes): return s.decode(defenc, 'surrogateescape') @@ -76,7 +76,7 @@ def safe_decode(s): def safe_encode(s): """Safely decodes a binary string to unicode""" - if isinstance(s, unicode): + if isinstance(s, str): return s.encode(defenc) elif isinstance(s, bytes): return s @@ -86,7 +86,7 @@ def safe_encode(s): def win_encode(s): """Encode unicodes for process arguments on Windows.""" - if isinstance(s, unicode): + if isinstance(s, str): return s.encode(locale.getpreferredencoding(False)) elif isinstance(s, bytes): return s @@ -155,7 +155,7 @@ def b(data): _unichr = chr bytes_chr = lambda code: bytes((code,)) else: - _unichr = unichr + _unichr = chr bytes_chr = chr def surrogateescape_handler(exc): diff --git a/git/config.py b/git/config.py index 7d962276e..d59624d1c 100644 --- a/git/config.py +++ b/git/config.py @@ -28,7 +28,7 @@ try: - import ConfigParser as cp + import configparser as cp except ImportError: # PY3 import configparser as cp @@ -441,7 +441,7 @@ def _write(self, fp): git compatible format""" def write_section(name, section_dict): fp.write(("[%s]\n" % name).encode(defenc)) - for (key, value) in section_dict.items(): + for (key, value) in list(section_dict.items()): if key != "__name__": fp.write(("\t%s = %s\n" % (key, self._value_to_string(value).replace('\n', '\n\t'))).encode(defenc)) # END if key is not __name__ @@ -449,7 +449,7 @@ def write_section(name, section_dict): if self._defaults: write_section(cp.DEFAULTSECT, self._defaults) - for name, value in self._sections.items(): + for name, value in list(self._sections.items()): write_section(name, value) def items(self, section_name): diff --git a/git/exc.py b/git/exc.py index 69ecc1d00..8f129dc53 100644 --- a/git/exc.py +++ b/git/exc.py @@ -31,7 +31,7 @@ class CommandError(UnicodeMixin, Exception): #: A unicode print-format with 2 `%s for `` and the rest, #: e.g. #: u"'%s' failed%s" - _msg = u"Cmd('%s') failed%s" + _msg = "Cmd('%s') failed%s" def __init__(self, command, status=None, stderr=None, stdout=None): if not isinstance(command, (tuple, list)): @@ -40,19 +40,19 @@ def __init__(self, command, status=None, stderr=None, stdout=None): self.status = status if status: if isinstance(status, Exception): - status = u"%s('%s')" % (type(status).__name__, safe_decode(str(status))) + status = "%s('%s')" % (type(status).__name__, safe_decode(str(status))) else: try: - status = u'exit code(%s)' % int(status) + status = 'exit code(%s)' % int(status) except: s = safe_decode(str(status)) - status = u"'%s'" % s if isinstance(status, string_types) else s + status = "'%s'" % s if isinstance(status, string_types) else s self._cmd = safe_decode(command[0]) - self._cmdline = u' '.join(safe_decode(i) for i in command) - self._cause = status and u" due to: %s" % status or "!" - self.stdout = stdout and u"\n stdout: '%s'" % safe_decode(stdout) or '' - self.stderr = stderr and u"\n stderr: '%s'" % safe_decode(stderr) or '' + self._cmdline = ' '.join(safe_decode(i) for i in command) + self._cause = status and " due to: %s" % status or "!" + self.stdout = stdout and "\n stdout: '%s'" % safe_decode(stdout) or '' + self.stderr = stderr and "\n stderr: '%s'" % safe_decode(stderr) or '' def __unicode__(self): return (self._msg + "\n cmdline: %s%s%s") % ( @@ -64,7 +64,7 @@ class GitCommandNotFound(CommandError): the GIT_PYTHON_GIT_EXECUTABLE environment variable""" def __init__(self, command, cause): super(GitCommandNotFound, self).__init__(command, cause) - self._msg = u"Cmd('%s') not found%s" + self._msg = "Cmd('%s') not found%s" class GitCommandError(CommandError): @@ -114,7 +114,7 @@ class HookExecutionError(CommandError): def __init__(self, command, status, stderr=None, stdout=None): super(HookExecutionError, self).__init__(command, status, stderr, stdout) - self._msg = u"Hook('%s') failed%s" + self._msg = "Hook('%s') failed%s" class RepositoryDirtyError(Exception): diff --git a/git/index/__init__.py b/git/index/__init__.py index 2516f01f8..b49de1dcd 100644 --- a/git/index/__init__.py +++ b/git/index/__init__.py @@ -1,6 +1,6 @@ """Initialize the index package""" # flake8: noqa -from __future__ import absolute_import + from .base import * from .typ import * diff --git a/git/index/base.py b/git/index/base.py index 4fee2aaee..e88f47aaf 100644 --- a/git/index/base.py +++ b/git/index/base.py @@ -171,7 +171,7 @@ def _deserialize(self, stream): def _entries_sorted(self): """:return: list of entries, in a sorted fashion, first by path, then by stage""" - return sorted(self.entries.values(), key=lambda e: (e.path, e.stage)) + return sorted(list(self.entries.values()), key=lambda e: (e.path, e.stage)) def _serialize(self, stream, ignore_extension_data=False): entries = self._entries_sorted() @@ -280,7 +280,7 @@ def new(cls, repo, *tree_sha): inst = cls(repo) # convert to entries dict - entries = dict(izip(((e.path, e.stage) for e in base_entries), + entries = dict(zip(((e.path, e.stage) for e in base_entries), (IndexEntry.from_base(e) for e in base_entries))) inst.entries = entries @@ -915,7 +915,7 @@ def move(self, items, skip_errors=False, **kwargs): # parse result - first 0:n/2 lines are 'checking ', the remaining ones # are the 'renaming' ones which we parse - for ln in xrange(int(len(mvlines) / 2), len(mvlines)): + for ln in range(int(len(mvlines) / 2), len(mvlines)): tokens = mvlines[ln].split(' to ') assert len(tokens) == 2, "Too many tokens in %s" % mvlines[ln] diff --git a/git/objects/__init__.py b/git/objects/__init__.py index 23b2416ae..64a044c32 100644 --- a/git/objects/__init__.py +++ b/git/objects/__init__.py @@ -2,7 +2,7 @@ Import all submodules main classes into the package space """ # flake8: noqa -from __future__ import absolute_import + import inspect @@ -22,5 +22,5 @@ # must come after submodule was made available -__all__ = [name for name, obj in locals().items() +__all__ = [name for name, obj in list(locals().items()) if not (name.startswith('_') or inspect.ismodule(obj))] diff --git a/git/objects/fun.py b/git/objects/fun.py index d5b3f9026..0c036d81b 100644 --- a/git/objects/fun.py +++ b/git/objects/fun.py @@ -22,7 +22,7 @@ def tree_to_stream(entries, write): for binsha, mode, name in entries: mode_str = b'' - for i in xrange(6): + for i in range(6): mode_str = bchr(((mode >> (i * 3)) & bit_mask) + ord_zero) + mode_str # END for each 8 octal value diff --git a/git/refs/__init__.py b/git/refs/__init__.py index ded8b1f7c..8f8303a21 100644 --- a/git/refs/__init__.py +++ b/git/refs/__init__.py @@ -1,5 +1,5 @@ # flake8: noqa -from __future__ import absolute_import + # import all modules in order, fix the names they require from .symbolic import * from .reference import * diff --git a/git/refs/log.py b/git/refs/log.py index 623a63db1..abe4123b3 100644 --- a/git/refs/log.py +++ b/git/refs/log.py @@ -48,7 +48,7 @@ def format(self): """:return: a string suitable to be placed in a reflog file""" act = self.actor time = self.time - return u"{0} {1} {2} <{3}> {4!s} {5}\t{6}\n".format(self.oldhexsha, + return "{0} {1} {2} <{3}> {4!s} {5}\t{6}\n".format(self.oldhexsha, self.newhexsha, act.name, act.email, @@ -222,7 +222,7 @@ def entry_at(cls, filepath, index): return RefLogEntry.from_line(fp.readlines()[index].strip()) else: # read until index is reached - for i in xrange(index + 1): + for i in range(index + 1): line = fp.readline() if not line: break diff --git a/git/remote.py b/git/remote.py index 60319ce14..1dd149898 100644 --- a/git/remote.py +++ b/git/remote.py @@ -35,6 +35,7 @@ SymbolicReference, TagReference ) +import collections log = logging.getLogger('git.remote') @@ -66,7 +67,7 @@ def to_progress_instance(progress): RemoteProgress(). """ # new API only needs progress as a function - if callable(progress): + if isinstance(progress, collections.Callable): return CallableRemoteProgress(progress) # where None is passed create a parser that eats the progress diff --git a/git/repo/__init__.py b/git/repo/__init__.py index 5619aa692..cfcc93b57 100644 --- a/git/repo/__init__.py +++ b/git/repo/__init__.py @@ -1,4 +1,4 @@ """Initialize the Repo package""" # flake8: noqa -from __future__ import absolute_import + from .base import * diff --git a/git/repo/base.py b/git/repo/base.py index 2f67a3411..bf880b2c1 100644 --- a/git/repo/base.py +++ b/git/repo/base.py @@ -726,9 +726,9 @@ def blame_incremental(self, rev, file, **kwargs): break yield BlameEntry(commits[hexsha], - range(lineno, lineno + num_lines), + list(range(lineno, lineno + num_lines)), safe_decode(orig_filename), - range(orig_lineno, orig_lineno + num_lines)) + list(range(orig_lineno, orig_lineno + num_lines))) def blame(self, rev, file, incremental=False, **kwargs): """The blame information for the given file at the given revision. diff --git a/git/repo/fun.py b/git/repo/fun.py index 39e55880f..6b7c47e75 100644 --- a/git/repo/fun.py +++ b/git/repo/fun.py @@ -287,7 +287,7 @@ def rev_parse(repo, rev): try: if token == "~": obj = to_commit(obj) - for _ in xrange(num): + for _ in range(num): obj = obj.parents[0] # END for each history item to walk elif token == "^": diff --git a/git/test/lib/__init__.py b/git/test/lib/__init__.py index 87e267520..bf0a82406 100644 --- a/git/test/lib/__init__.py +++ b/git/test/lib/__init__.py @@ -9,5 +9,5 @@ from .asserts import * from .helper import * -__all__ = [name for name, obj in locals().items() +__all__ = [name for name, obj in list(locals().items()) if not (name.startswith('_') or inspect.ismodule(obj))] diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 729c76a4f..101e00547 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -3,7 +3,7 @@ # # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -from __future__ import print_function + import contextlib from functools import wraps diff --git a/git/test/performance/test_commit.py b/git/test/performance/test_commit.py index 322d3c9fc..183c7c8b9 100644 --- a/git/test/performance/test_commit.py +++ b/git/test/performance/test_commit.py @@ -3,7 +3,7 @@ # # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -from __future__ import print_function + from io import BytesIO from time import time import sys @@ -90,7 +90,7 @@ def test_commit_serialization(self): nc = 5000 st = time() - for i in xrange(nc): + for i in range(nc): cm = Commit(rwrepo, Commit.NULL_BIN_SHA, hc.tree, hc.author, hc.authored_date, hc.author_tz_offset, hc.committer, hc.committed_date, hc.committer_tz_offset, diff --git a/git/test/performance/test_odb.py b/git/test/performance/test_odb.py index 425af84a5..9156db361 100644 --- a/git/test/performance/test_odb.py +++ b/git/test/performance/test_odb.py @@ -1,5 +1,5 @@ """Performance tests for object store""" -from __future__ import print_function + import sys from time import time diff --git a/git/test/performance/test_streams.py b/git/test/performance/test_streams.py index 3909d8ff1..8d80cff5d 100644 --- a/git/test/performance/test_streams.py +++ b/git/test/performance/test_streams.py @@ -1,5 +1,5 @@ """Performance data streaming performance""" -from __future__ import print_function + import os import subprocess diff --git a/git/test/test_base.py b/git/test/test_base.py index 69f161bee..ac9caeb19 100644 --- a/git/test/test_base.py +++ b/git/test/test_base.py @@ -126,7 +126,7 @@ def test_with_rw_remote_and_rw_repo(self, rw_repo, rw_remote_repo): "Unicode woes, see https://github.com/gitpython-developers/GitPython/pull/519") @with_rw_repo('0.1.6') def test_add_unicode(self, rw_repo): - filename = u"שלום.txt" + filename = "שלום.txt" file_path = osp.join(rw_repo.working_dir, filename) diff --git a/git/test/test_commit.py b/git/test/test_commit.py index fbb1c244e..20fe13b3b 100644 --- a/git/test/test_commit.py +++ b/git/test/test_commit.py @@ -4,7 +4,7 @@ # # This module is part of GitPython and is released under # the BSD License: http://www.opensource.org/licenses/bsd-license.php -from __future__ import print_function + from datetime import datetime from io import BytesIO @@ -125,7 +125,7 @@ def check_entries(d): check_entries(stats.total) assert "files" in stats.total - for filepath, d in stats.files.items(): # @UnusedVariable + for filepath, d in list(stats.files.items()): # @UnusedVariable check_entries(d) # END for each stated file @@ -141,9 +141,9 @@ def check_entries(d): def test_unicode_actor(self): # assure we can parse unicode actors correctly - name = u"Üäöß ÄußÉ" + name = "Üäöß ÄußÉ" self.assertEqual(len(name), 9) - special = Actor._from_string(u"%s " % name) + special = Actor._from_string("%s " % name) self.assertEqual(special.name, name) assert isinstance(special.name, text_type) @@ -293,10 +293,10 @@ def test_serialization_unicode_support(self): assert isinstance(cmt.message, text_type) # it automatically decodes it as such assert isinstance(cmt.author.name, text_type) # same here - cmt.message = u"üäêèß" + cmt.message = "üäêèß" self.assertEqual(len(cmt.message), 5) - cmt.author.name = u"äüß" + cmt.author.name = "äüß" self.assertEqual(len(cmt.author.name), 3) cstream = BytesIO() @@ -318,7 +318,7 @@ def test_invalid_commit(self): with open(fixture_path('commit_invalid_data'), 'rb') as fd: cmt._deserialize(fd) - self.assertEqual(cmt.author.name, u'E.Azer Ko�o�o�oculu', cmt.author.name) + self.assertEqual(cmt.author.name, 'E.Azer Ko�o�o�oculu', cmt.author.name) self.assertEqual(cmt.author.email, 'azer@kodfabrik.com', cmt.author.email) def test_gpgsig(self): diff --git a/git/test/test_diff.py b/git/test/test_diff.py index 48a5a641f..4309a48a6 100644 --- a/git/test/test_diff.py +++ b/git/test/test_diff.py @@ -94,8 +94,8 @@ def test_diff_with_rename(self): diff = diffs[0] assert_true(diff.renamed_file) assert_true(diff.renamed) - assert_equal(diff.rename_from, u'Jérôme') - assert_equal(diff.rename_to, u'müller') + assert_equal(diff.rename_from, 'Jérôme') + assert_equal(diff.rename_to, 'müller') assert_equal(diff.raw_rename_from, b'J\xc3\xa9r\xc3\xb4me') assert_equal(diff.raw_rename_to, b'm\xc3\xbcller') assert isinstance(str(diff), str) @@ -173,29 +173,29 @@ def test_diff_unsafe_paths(self): res = Diff._index_from_patch_format(None, output) # The "Additions" - self.assertEqual(res[0].b_path, u'path/ starting with a space') - self.assertEqual(res[1].b_path, u'path/"with-quotes"') - self.assertEqual(res[2].b_path, u"path/'with-single-quotes'") - self.assertEqual(res[3].b_path, u'path/ending in a space ') - self.assertEqual(res[4].b_path, u'path/with\ttab') - self.assertEqual(res[5].b_path, u'path/with\nnewline') - self.assertEqual(res[6].b_path, u'path/with spaces') - self.assertEqual(res[7].b_path, u'path/with-question-mark?') - self.assertEqual(res[8].b_path, u'path/¯\\_(ツ)_|¯') - self.assertEqual(res[9].b_path, u'path/💩.txt') + self.assertEqual(res[0].b_path, 'path/ starting with a space') + self.assertEqual(res[1].b_path, 'path/"with-quotes"') + self.assertEqual(res[2].b_path, "path/'with-single-quotes'") + self.assertEqual(res[3].b_path, 'path/ending in a space ') + self.assertEqual(res[4].b_path, 'path/with\ttab') + self.assertEqual(res[5].b_path, 'path/with\nnewline') + self.assertEqual(res[6].b_path, 'path/with spaces') + self.assertEqual(res[7].b_path, 'path/with-question-mark?') + self.assertEqual(res[8].b_path, 'path/¯\\_(ツ)_|¯') + self.assertEqual(res[9].b_path, 'path/💩.txt') self.assertEqual(res[9].b_rawpath, b'path/\xf0\x9f\x92\xa9.txt') - self.assertEqual(res[10].b_path, u'path/�-invalid-unicode-path.txt') + self.assertEqual(res[10].b_path, 'path/�-invalid-unicode-path.txt') self.assertEqual(res[10].b_rawpath, b'path/\x80-invalid-unicode-path.txt') # The "Moves" # NOTE: The path prefixes a/ and b/ here are legit! We're actually # verifying that it's not "a/a/" that shows up, see the fixture data. - self.assertEqual(res[11].a_path, u'a/with spaces') # NOTE: path a/ here legit! - self.assertEqual(res[11].b_path, u'b/with some spaces') # NOTE: path b/ here legit! - self.assertEqual(res[12].a_path, u'a/ending in a space ') - self.assertEqual(res[12].b_path, u'b/ending with space ') - self.assertEqual(res[13].a_path, u'a/"with-quotes"') - self.assertEqual(res[13].b_path, u'b/"with even more quotes"') + self.assertEqual(res[11].a_path, 'a/with spaces') # NOTE: path a/ here legit! + self.assertEqual(res[11].b_path, 'b/with some spaces') # NOTE: path b/ here legit! + self.assertEqual(res[12].a_path, 'a/ending in a space ') + self.assertEqual(res[12].b_path, 'b/ending with space ') + self.assertEqual(res[13].a_path, 'a/"with-quotes"') + self.assertEqual(res[13].b_path, 'b/"with even more quotes"') def test_diff_patch_format(self): # test all of the 'old' format diffs for completness - it should at least @@ -213,7 +213,7 @@ def test_diff_with_spaces(self): data = StringProcessAdapter(fixture('diff_file_with_spaces')) diff_index = Diff._index_from_patch_format(self.rorepo, data) self.assertIsNone(diff_index[0].a_path, repr(diff_index[0].a_path)) - self.assertEqual(diff_index[0].b_path, u'file with spaces', repr(diff_index[0].b_path)) + self.assertEqual(diff_index[0].b_path, 'file with spaces', repr(diff_index[0].b_path)) def test_diff_interface(self): # test a few variations of the main diff routine @@ -257,7 +257,7 @@ def test_diff_interface(self): # assert we could always find at least one instance of the members we # can iterate in the diff index - if not this indicates its not working correctly # or our test does not span the whole range of possibilities - for key, value in assertion_map.items(): + for key, value in list(assertion_map.items()): self.assertIsNotNone(value, "Did not find diff for %s" % key) # END for each iteration type diff --git a/git/test/test_docs.py b/git/test/test_docs.py index cbbd94471..16a3d748e 100644 --- a/git/test/test_docs.py +++ b/git/test/test_docs.py @@ -126,7 +126,7 @@ def test_init_repo_object(self, rw_dir): class MyProgressPrinter(RemoteProgress): def update(self, op_code, cur_count, max_count=None, message=''): - print(op_code, cur_count, max_count, cur_count / (max_count or 100.0), message or "NO MESSAGE") + print((op_code, cur_count, max_count, cur_count / (max_count or 100.0), message or "NO MESSAGE")) # end self.assertEqual(len(cloned_repo.remotes), 1) # we have been cloned, so should be one remote @@ -134,7 +134,7 @@ def update(self, op_code, cur_count, max_count=None, message=''): origin = bare_repo.create_remote('origin', url=cloned_repo.working_tree_dir) assert origin.exists() for fetch_info in origin.fetch(progress=MyProgressPrinter()): - print("Updated %s to %s" % (fetch_info.ref, fetch_info.commit)) + print(("Updated %s to %s" % (fetch_info.ref, fetch_info.commit))) # create a local branch at the latest fetched master. We specify the name statically, but you have all # information to do it programatically as well. bare_master = bare_repo.create_head('master', origin.refs.master) @@ -350,7 +350,7 @@ def test_references_and_objects(self, rw_dir): # The index contains all blobs in a flat list assert len(list(index.iter_blobs())) == len([o for o in repo.head.commit.tree.traverse() if o.type == 'blob']) # Access blob objects - for (path, stage), entry in index.entries.items(): # @UnusedVariable + for (path, stage), entry in list(index.entries.items()): # @UnusedVariable pass new_file_path = osp.join(repo.working_tree_dir, 'new-file-name') open(new_file_path, 'w').close() diff --git a/git/test/test_fun.py b/git/test/test_fun.py index b472fe19c..a70ac2989 100644 --- a/git/test/test_fun.py +++ b/git/test/test_fun.py @@ -257,7 +257,7 @@ def test_tree_traversal_single(self): @skipIf(PY3, 'odd types returned ... maybe figure it out one day') def test_tree_entries_from_data_with_failing_name_decode_py2(self): r = tree_entries_from_data(b'100644 \x9f\0aaa') - assert r == [('aaa', 33188, u'\udc9f')], r + assert r == [('aaa', 33188, '\udc9f')], r @skipIf(not PY3, 'odd types returned ... maybe figure it out one day') def test_tree_entries_from_data_with_failing_name_decode_py3(self): diff --git a/git/test/test_git.py b/git/test/test_git.py index 3c8b6f828..24889d50c 100644 --- a/git/test/test_git.py +++ b/git/test/test_git.py @@ -56,7 +56,7 @@ def test_call_process_calls_execute(self, git): assert_equal(git.call_args, ((['git', 'version'],), {})) def test_call_unpack_args_unicode(self): - args = Git._Git__unpack_args(u'Unicode€™') + args = Git._Git__unpack_args('Unicode€™') if PY3: mangled_value = 'Unicode\u20ac\u2122' else: @@ -64,7 +64,7 @@ def test_call_unpack_args_unicode(self): assert_equal(args, [mangled_value]) def test_call_unpack_args(self): - args = Git._Git__unpack_args(['git', 'log', '--', u'Unicode€™']) + args = Git._Git__unpack_args(['git', 'log', '--', 'Unicode€™']) if PY3: mangled_value = 'Unicode\u20ac\u2122' else: diff --git a/git/test/test_index.py b/git/test/test_index.py index e8d38a09a..82ff807df 100644 --- a/git/test/test_index.py +++ b/git/test/test_index.py @@ -63,7 +63,7 @@ def __init__(self, *args): def _assert_fprogress(self, entries): self.assertEqual(len(entries), len(self._fprogress_map)) - for path, call_count in self._fprogress_map.items(): # @UnusedVariable + for path, call_count in list(self._fprogress_map.items()): # @UnusedVariable self.assertEqual(call_count, 2) # END for each item in progress map self._reset_progress() @@ -101,7 +101,7 @@ def test_index_file_base(self): assert index.version > 0 # test entry - entry = next(iter(index.entries.values())) + entry = next(iter(list(index.entries.values()))) for attr in ("path", "ctime", "mtime", "dev", "inode", "mode", "uid", "gid", "size", "binsha", "hexsha", "stage"): getattr(entry, attr) @@ -115,7 +115,7 @@ def test_index_file_base(self): # test stage index_merge = IndexFile(self.rorepo, fixture_path("index_merge")) self.assertEqual(len(index_merge.entries), 106) - assert len(list(e for e in index_merge.entries.values() if e.stage != 0)) + assert len(list(e for e in list(index_merge.entries.values()) if e.stage != 0)) # write the data - it must match the original tmpfile = tempfile.mktemp() @@ -135,7 +135,7 @@ def _cmp_tree_index(self, tree, index): blist.append(blob) # END for each blob in tree if len(blist) != len(index.entries): - iset = set(k[0] for k in index.entries.keys()) + iset = set(k[0] for k in list(index.entries.keys())) bset = set(b.path for b in blist) raise AssertionError("CMP Failed: Missing entries in index: %s, missing in tree: %s" % (bset - iset, iset - bset)) @@ -183,7 +183,7 @@ def test_index_file_from_tree(self, rw_repo): # merge three trees - here we have a merge conflict three_way_index = IndexFile.from_tree(rw_repo, common_ancestor_sha, cur_sha, other_sha) - assert len(list(e for e in three_way_index.entries.values() if e.stage != 0)) + assert len(list(e for e in list(three_way_index.entries.values()) if e.stage != 0)) # ITERATE BLOBS merge_required = lambda t: t[0] != 0 @@ -205,7 +205,7 @@ def test_index_file_from_tree(self, rw_repo): assert unmerged_blob_map # pick the first blob at the first stage we find and use it as resolved version - three_way_index.resolve_blobs(l[0][1] for l in unmerged_blob_map.values()) + three_way_index.resolve_blobs(l[0][1] for l in list(unmerged_blob_map.values())) tree = three_way_index.write_tree() assert isinstance(tree, Tree) num_blobs = 0 @@ -422,7 +422,7 @@ def test_index_mutation(self, rw_repo): num_entries = len(index.entries) cur_head = rw_repo.head - uname = u"Thomas Müller" + uname = "Thomas Müller" umail = "sd@company.com" with rw_repo.config_writer() as writer: writer.set_value("user", "name", uname) @@ -433,7 +433,7 @@ def test_index_mutation(self, rw_repo): # IndexEntries def mixed_iterator(): count = 0 - for entry in index.entries.values(): + for entry in list(index.entries.values()): type_id = count % 4 if type_id == 0: # path yield entry.path @@ -477,7 +477,7 @@ def mixed_iterator(): # TEST COMMITTING # commit changed index cur_commit = cur_head.commit - commit_message = u"commit default head by Frèderic Çaufl€" + commit_message = "commit default head by Frèderic Çaufl€" new_commit = index.commit(commit_message, head=False) assert cur_commit != new_commit @@ -493,13 +493,13 @@ def mixed_iterator(): # commit with other actor cur_commit = cur_head.commit - my_author = Actor(u"Frèderic Çaufl€", "author@example.com") - my_committer = Actor(u"Committing Frèderic Çaufl€", "committer@example.com") + my_author = Actor("Frèderic Çaufl€", "author@example.com") + my_committer = Actor("Committing Frèderic Çaufl€", "committer@example.com") commit_actor = index.commit(commit_message, author=my_author, committer=my_committer) assert cur_commit != commit_actor - self.assertEqual(commit_actor.author.name, u"Frèderic Çaufl€") + self.assertEqual(commit_actor.author.name, "Frèderic Çaufl€") self.assertEqual(commit_actor.author.email, "author@example.com") - self.assertEqual(commit_actor.committer.name, u"Committing Frèderic Çaufl€") + self.assertEqual(commit_actor.committer.name, "Committing Frèderic Çaufl€") self.assertEqual(commit_actor.committer.email, "committer@example.com") self.assertEqual(commit_actor.message, commit_message) self.assertEqual(commit_actor.parents[0], cur_commit) @@ -509,11 +509,11 @@ def mixed_iterator(): # commit with author_date and commit_date cur_commit = cur_head.commit - commit_message = u"commit with dates by Avinash Sajjanshetty" + commit_message = "commit with dates by Avinash Sajjanshetty" new_commit = index.commit(commit_message, author_date="2006-04-07T22:13:13", commit_date="2005-04-07T22:13:13") assert cur_commit != new_commit - print(new_commit.authored_date, new_commit.committed_date) + print((new_commit.authored_date, new_commit.committed_date)) self.assertEqual(new_commit.message, commit_message) self.assertEqual(new_commit.authored_date, 1144447993) self.assertEqual(new_commit.committed_date, 1112911993) @@ -843,7 +843,7 @@ def test_add_utf8P_path(self, rw_dir): # NOTE: fp is not a Unicode object in python 2 (which is the source of the problem) fp = osp.join(rw_dir, 'ø.txt') with open(fp, 'wb') as fs: - fs.write(u'content of ø'.encode('utf-8')) + fs.write('content of ø'.encode('utf-8')) r = Repo.init(rw_dir) r.index.add([fp]) diff --git a/git/test/test_remote.py b/git/test/test_remote.py index ad9210f64..516465bb2 100644 --- a/git/test/test_remote.py +++ b/git/test/test_remote.py @@ -97,7 +97,7 @@ def make_assertion(self): assert self._stages_per_op # must have seen all stages - for op, stages in self._stages_per_op.items(): # @UnusedVariable + for op, stages in list(self._stages_per_op.items()): # @UnusedVariable assert stages & self.STAGE_MASK == self.STAGE_MASK # END for each op/stage diff --git a/git/test/test_repo.py b/git/test/test_repo.py index 86019b73a..76a70bd2f 100644 --- a/git/test/test_repo.py +++ b/git/test/test_repo.py @@ -396,17 +396,17 @@ def test_blame_incremental(self, git): # Check all outputted line numbers ranges = flatten([entry.linenos for entry in blame_output]) - self.assertEqual(ranges, flatten([range(2, 3), range(14, 15), range(1, 2), range(3, 14), range(15, 17)])) + self.assertEqual(ranges, flatten([list(range(2, 3)), list(range(14, 15)), list(range(1, 2)), list(range(3, 14)), list(range(15, 17))])) commits = [entry.commit.hexsha[:7] for entry in blame_output] self.assertEqual(commits, ['82b8902', '82b8902', 'c76852d', 'c76852d', 'c76852d']) # Original filenames - self.assertSequenceEqual([entry.orig_path for entry in blame_output], [u'AUTHORS'] * len(blame_output)) + self.assertSequenceEqual([entry.orig_path for entry in blame_output], ['AUTHORS'] * len(blame_output)) # Original line numbers orig_ranges = flatten([entry.orig_linenos for entry in blame_output]) - self.assertEqual(orig_ranges, flatten([range(2, 3), range(14, 15), range(1, 2), range(2, 13), range(13, 15)])) # noqa E501 + self.assertEqual(orig_ranges, flatten([list(range(2, 3)), list(range(14, 15)), list(range(1, 2)), list(range(2, 13)), list(range(13, 15))])) # noqa E501 @patch.object(Git, '_call_process') def test_blame_complex_revision(self, git): @@ -430,10 +430,10 @@ def test_untracked_files(self, rwrepo): (rwrepo.git.add, True), )): base = rwrepo.working_tree_dir - files = (join_path_native(base, u"%i_test _myfile" % run), + files = (join_path_native(base, "%i_test _myfile" % run), join_path_native(base, "%i_test_other_file" % run), - join_path_native(base, u"%i__çava verböten" % run), - join_path_native(base, u"%i_çava-----verböten" % run)) + join_path_native(base, "%i__çava verböten" % run), + join_path_native(base, "%i_çava-----verböten" % run)) num_recently_untracked = 0 for fpath in files: @@ -677,7 +677,7 @@ def test_rev_parse(self): self.assertEqual(obj.type, ref.object.type) num_resolved += 1 except (BadName, BadObject): - print("failed on %s" % path_section) + print(("failed on %s" % path_section)) # is fine, in case we have something like 112, which belongs to remotes/rname/merge-requests/112 pass # END exception handling diff --git a/git/test/test_submodule.py b/git/test/test_submodule.py index 9e79a72ca..f5968ebb9 100644 --- a/git/test/test_submodule.py +++ b/git/test/test_submodule.py @@ -35,7 +35,7 @@ class TestRootProgress(RootUpdateProgress): """Just prints messages, for now without checking the correctness of the states""" def update(self, op, cur_count, max_count, message=''): - print(op, cur_count, max_count, message) + print((op, cur_count, max_count, message)) prog = TestRootProgress() diff --git a/git/util.py b/git/util.py index 5553a0aa9..9a7d32597 100644 --- a/git/util.py +++ b/git/util.py @@ -565,7 +565,7 @@ def __str__(self): return self.name def __repr__(self): - return u'">' % (self.name, self.email) + return '">' % (self.name, self.email) @classmethod def _from_string(cls, string): diff --git a/setup.py b/setup.py index ea1b6316d..ac8a09c10 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ #!/usr/bin/env python -from __future__ import print_function + try: from setuptools import setup, find_packages except ImportError: @@ -75,7 +75,7 @@ def _stamp_version(filename): try: if 'bdist_wheel' not in sys.argv: - for key, value in extras_require.items(): + for key, value in list(extras_require.items()): if key.startswith(':') and pkg_resources.evaluate_marker(key[1:]): install_requires.extend(value) except Exception: @@ -83,7 +83,7 @@ def _stamp_version(filename): 'Something went wrong calculating platform specific dependencies, so ' "you're getting them all!" ) - for key, value in extras_require.items(): + for key, value in list(extras_require.items()): if key.startswith(':'): install_requires.extend(value) # end pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy