Skip to content

Commit

Permalink
remove last bits of python2 support (#80)
Browse files Browse the repository at this point in the history
Remove string type compat check since py3.8 is the now the minimum.
  • Loading branch information
corytodd authored Jul 14, 2024
1 parent d08d8ac commit f779b54
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions jsondiff/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import sys
import json
import yaml

Expand All @@ -15,15 +14,6 @@
# - when source is list and diff is a list patch dict -> patch
# - else -> replacement

# Python 2 vs 3
PY3 = sys.version_info[0] == 3

if PY3:
string_types = str
else:
string_types = basestring


class JsonDumper:
def __init__(self, **kwargs):
self.kwargs = kwargs
Expand Down Expand Up @@ -61,7 +51,7 @@ def __call__(self, src):
:param src: str|file-like source
:return: dict parsed data
"""
if isinstance(src, string_types):
if isinstance(src, str):
return json.loads(src, **self.kwargs)
else:
return json.load(src, **self.kwargs)
Expand Down Expand Up @@ -1020,7 +1010,7 @@ def _unescape(self, x):
"""
Unescapes a string that has been escaped.
"""
if isinstance(x, string_types):
if isinstance(x, str):
sym = self._symbol_map.get(x, None)
if sym is not None:
return sym
Expand Down Expand Up @@ -1051,7 +1041,7 @@ def _escape(self, o):
"""
if type(o) is Symbol:
return self.options.escape_str + o.label
if isinstance(o, string_types) and o.startswith(self.options.escape_str):
if isinstance(o, str) and o.startswith(self.options.escape_str):
return self.options.escape_str + o
return o

Expand Down

0 comments on commit f779b54

Please sign in to comment.