GeezerVison is showing github.com — Remove and replace compat.string_types · gitpython-developers/GitPython@768b9ff
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: git/cmd.py +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 21 | 21 | from textwrap import dedent | 22 | 22 |
| 23 | 23 | from git.compat import ( | 24 | | - string_types, | 25 | 24 | defenc, | 26 | 25 | force_bytes, | 27 | 26 | safe_decode, | @@ -1038,7 +1037,7 @@ def _prepare_ref(self, ref): | 1038 | 1037 | if isinstance(ref, bytes): | 1039 | 1038 | # Assume 40 bytes hexsha - bin-to-ascii for some reason returns bytes, not text | 1040 | 1039 | refstr = ref.decode('ascii') | 1041 | | - elif not isinstance(ref, string_types): | | 1040 | + elif not isinstance(ref, str): | 1042 | 1041 | refstr = str(ref) # could be ref-object | 1043 | 1042 |
| 1044 | 1043 | if not refstr.endswith("\n"): | |
Collapse file Copy file name to clipboardExpand all lines: git/compat.py -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
| 13 | 13 |
| 14 | 14 |
| 15 | 15 | from gitdb.utils.encoding import ( | 16 | | - string_types, # @UnusedImport | 17 | 16 | text_type, # @UnusedImport | 18 | 17 | force_bytes, # @UnusedImport | 19 | 18 | force_text # @UnusedImport | |
Collapse file Copy file name to clipboardExpand all lines: git/config.py +3-4Lines changed: 3 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 16 | 16 | from collections import OrderedDict | 17 | 17 |
| 18 | 18 | from git.compat import ( | 19 | | - string_types, | 20 | 19 | defenc, | 21 | 20 | force_text, | 22 | 21 | with_metaclass, | @@ -302,7 +301,7 @@ def _acquire_lock(self): | 302 | 301 | # END single file check | 303 | 302 |
| 304 | 303 | 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): | 306 | 305 | file_or_files = self._file_or_files.name | 307 | 306 | # END get filename from handle/stream | 308 | 307 | # initialize lock base - we want to write | @@ -578,7 +577,7 @@ def write(self): | 578 | 577 | fp = self._file_or_files | 579 | 578 |
| 580 | 579 | # 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)) | 582 | 581 | if is_file_lock: | 583 | 582 | self._lock._obtain_lock() | 584 | 583 | if not hasattr(fp, "seek"): | @@ -670,7 +669,7 @@ def _string_to_value(self, valuestr): | 670 | 669 | if vl == 'true': | 671 | 670 | return True | 672 | 671 |
| 673 | | - if not isinstance(valuestr, string_types): | | 672 | + if not isinstance(valuestr, str): | 674 | 673 | raise TypeError( | 675 | 674 | "Invalid value type: only int, long, float and str are allowed", | 676 | 675 | valuestr) | |
Collapse file Copy file name to clipboardExpand all lines: git/exc.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 | """ Module containing all exceptions thrown throughout the git package, """ | 7 | 7 |
| 8 | 8 | 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 | 10 | 10 |
| 11 | 11 |
| 12 | 12 | class GitError(Exception): | @@ -50,7 +50,7 @@ def __init__(self, command, status=None, stderr=None, stdout=None): | 50 | 50 | status = u'exit code(%s)' % int(status) | 51 | 51 | except (ValueError, TypeError): | 52 | 52 | 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 | 54 | 54 |
| 55 | 55 | self._cmd = safe_decode(command[0]) | 56 | 56 | self._cmdline = u' '.join(safe_decode(i) for i in command) | |
Collapse file Copy file name to clipboardExpand all lines: git/index/base.py +4-5Lines changed: 4 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 11 | 11 | import tempfile | 12 | 12 |
| 13 | 13 | from git.compat import ( | 14 | | - string_types, | 15 | 14 | force_bytes, | 16 | 15 | defenc, | 17 | 16 | ) | @@ -571,7 +570,7 @@ def _preprocess_add_items(self, items): | 571 | 570 | items = [items] | 572 | 571 |
| 573 | 572 | for item in items: | 574 | | - if isinstance(item, string_types): | | 573 | + if isinstance(item, str): | 575 | 574 | paths.append(self._to_relative_path(item)) | 576 | 575 | elif isinstance(item, (Blob, Submodule)): | 577 | 576 | entries.append(BaseIndexEntry.from_blob(item)) | @@ -808,7 +807,7 @@ def _items_to_rela_paths(self, items): | 808 | 807 | for item in items: | 809 | 808 | if isinstance(item, (BaseIndexEntry, (Blob, Submodule))): | 810 | 809 | paths.append(self._to_relative_path(item.path)) | 811 | | - elif isinstance(item, string_types): | | 810 | + elif isinstance(item, str): | 812 | 811 | paths.append(self._to_relative_path(item)) | 813 | 812 | else: | 814 | 813 | raise TypeError("Invalid item type: %r" % item) | @@ -1087,7 +1086,7 @@ def handle_stderr(proc, iter_checked_out_files): | 1087 | 1086 | handle_stderr(proc, rval_iter) | 1088 | 1087 | return rval_iter | 1089 | 1088 | else: | 1090 | | - if isinstance(paths, string_types): | | 1089 | + if isinstance(paths, str): | 1091 | 1090 | paths = [paths] | 1092 | 1091 |
| 1093 | 1092 | # 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 | 1224 | 1223 | # index against anything but None is a reverse diff with the respective | 1225 | 1224 | # item. Handle existing -R flags properly. Transform strings to the object | 1226 | 1225 | # so that we can call diff on it | 1227 | | - if isinstance(other, string_types): | | 1226 | + if isinstance(other, str): | 1228 | 1227 | other = self.repo.rev_parse(other) | 1229 | 1228 | # END object conversion | 1230 | 1229 |
| |
Collapse file Copy file name to clipboardExpand all lines: git/objects/submodule/base.py +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 9 | 9 | import git | 10 | 10 | from git.cmd import Git | 11 | 11 | from git.compat import ( | 12 | | - string_types, | 13 | 12 | defenc, | 14 | 13 | is_win, | 15 | 14 | ) | @@ -110,7 +109,7 @@ def __init__(self, repo, binsha, mode=None, path=None, name=None, parent_commit= | 110 | 109 | if url is not None: | 111 | 110 | self._url = url | 112 | 111 | if branch_path is not None: | 113 | | - assert isinstance(branch_path, string_types) | | 112 | + assert isinstance(branch_path, str) | 114 | 113 | self._branch_path = branch_path | 115 | 114 | if name is not None: | 116 | 115 | self._name = name | |
Collapse file Copy file name to clipboardExpand all lines: git/objects/tree.py +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 11 | 11 | from .base import IndexObject | 12 | 12 | from .blob import Blob | 13 | 13 | from .submodule.base import Submodule | 14 | | -from git.compat import string_types | 15 | 14 |
| 16 | 15 | from .fun import ( | 17 | 16 | tree_entries_from_data, | @@ -290,7 +289,7 @@ def __getitem__(self, item): | 290 | 289 | info = self._cache[item] | 291 | 290 | return self._map_id_to_type[info[1] >> 12](self.repo, info[0], info[1], join_path(self.path, info[2])) | 292 | 291 |
| 293 | | - if isinstance(item, string_types): | | 292 | + if isinstance(item, str): | 294 | 293 | # compatibility | 295 | 294 | return self.join(item) | 296 | 295 | # END index is basestring | |
Collapse file Copy file name to clipboardExpand all lines: git/refs/log.py +2-5Lines changed: 2 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import re | 2 | 2 | import time | 3 | 3 |
| 4 | | -from git.compat import ( | 5 | | - string_types, | 6 | | - defenc | 7 | | -) | | 4 | +from git.compat import defenc | 8 | 5 | from git.objects.util import ( | 9 | 6 | parse_date, | 10 | 7 | Serializable, | @@ -185,7 +182,7 @@ def iter_entries(cls, stream): | 185 | 182 | :param stream: file-like object containing the revlog in its native format | 186 | 183 | or basestring instance pointing to a file to read""" | 187 | 184 | new_entry = RefLogEntry.from_line | 188 | | - if isinstance(stream, string_types): | | 185 | + if isinstance(stream, str): | 189 | 186 | stream = file_contents_ro_filepath(stream) | 190 | 187 | # END handle stream type | 191 | 188 | while True: | |
Collapse file Copy file name to clipboardExpand all lines: git/refs/symbolic.py +2-5Lines changed: 2 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | import os | 2 | 2 |
| 3 | | -from git.compat import ( | 4 | | - string_types, | 5 | | - defenc | 6 | | -) | | 3 | +from git.compat import defenc | 7 | 4 | from git.objects import Object, Commit | 8 | 5 | from git.util import ( | 9 | 6 | join_path, | @@ -300,7 +297,7 @@ def set_reference(self, ref, logmsg=None): | 300 | 297 | elif isinstance(ref, Object): | 301 | 298 | obj = ref | 302 | 299 | write_value = ref.hexsha | 303 | | - elif isinstance(ref, string_types): | | 300 | + elif isinstance(ref, str): | 304 | 301 | try: | 305 | 302 | obj = self.repo.rev_parse(ref + "^{}") # optionally deref tags | 306 | 303 | write_value = obj.hexsha | |
Collapse file Copy file name to clipboardExpand all lines: git/test/lib/helper.py +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 17 | 17 | import time | 18 | 18 | import unittest | 19 | 19 |
| 20 | | -from git.compat import string_types, is_win | | 20 | +from git.compat import is_win | 21 | 21 | from git.util import rmtree, cwd | 22 | 22 | import gitdb | 23 | 23 |
| @@ -117,7 +117,7 @@ def with_rw_repo(working_tree_ref, bare=False): | 117 | 117 | To make working with relative paths easier, the cwd will be set to the working | 118 | 118 | dir of the repository. | 119 | 119 | """ | 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" | 121 | 121 |
| 122 | 122 | def argument_passer(func): | 123 | 123 | @wraps(func) | @@ -248,7 +248,7 @@ def case(self, rw_repo, rw_daemon_repo) | 248 | 248 | """ | 249 | 249 | from git import Git, Remote # To avoid circular deps. | 250 | 250 |
| 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" | 252 | 252 |
| 253 | 253 | def argument_passer(func): | 254 | 254 |
| |
|