From a780e1581d6f95a52f3dca1ad023483c04cd05c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20K=C5=82oczko?= Date: Sat, 29 Jun 2024 08:25:34 +0000 Subject: [PATCH 1/2] really drop python<=3.7 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Filter all codede over `pyupgrade --py38-plus`. Signed-off-by: Tomasz Kłoczko --- docs/conf.py | 13 ++++++------- jsondiff/__init__.py | 20 ++++++++++---------- jsondiff/cli.py | 2 +- jsondiff/symbols.py | 3 +-- tests/generate_readme.py | 1 - 5 files changed, 18 insertions(+), 21 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index 31814bb..aa799b6 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,3 @@ -# -*- coding: utf-8 -*- # # jsondiff documentation build configuration file, created by # sphinx-quickstart on Fri Nov 13 17:39:49 2015. @@ -46,9 +45,9 @@ master_doc = 'index' # General information about the project. -project = u'jsondiff' -copyright = u'2015, Eric Reynolds' -author = u'Eric Reynolds' +project = 'jsondiff' +copyright = '2015, Eric Reynolds' +author = 'Eric Reynolds' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -222,8 +221,8 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'jsondiff.tex', u'jsondiff Documentation', - u'Eric Reynolds', 'manual'), + (master_doc, 'jsondiff.tex', 'jsondiff Documentation', + 'Eric Reynolds', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -266,7 +265,7 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'jsondiff', u'jsondiff Documentation', + (master_doc, 'jsondiff', 'jsondiff Documentation', author, 'jsondiff', 'One line description of project.', 'Miscellaneous'), ] diff --git a/jsondiff/__init__.py b/jsondiff/__init__.py index 8dc598a..eb2fadd 100644 --- a/jsondiff/__init__.py +++ b/jsondiff/__init__.py @@ -24,7 +24,7 @@ string_types = basestring -class JsonDumper(object): +class JsonDumper: def __init__(self, **kwargs): self.kwargs = kwargs @@ -38,7 +38,7 @@ def __call__(self, obj, dest=None): default_dumper = JsonDumper() -class YamlDumper(object): +class YamlDumper: """Write object as YAML string""" def __init__(self, **kwargs): @@ -52,7 +52,7 @@ def __call__(self, obj, dest=None): """ return yaml.dump(obj, dest, **self.kwargs) -class JsonLoader(object): +class JsonLoader: def __init__(self, **kwargs): self.kwargs = kwargs @@ -70,7 +70,7 @@ def __call__(self, src): default_loader = JsonLoader() -class YamlLoader(object): +class YamlLoader: """Load YAML data from file-like object or string""" def __call__(self, src): @@ -121,7 +121,7 @@ def serialize_data(self, obj, stream): dumper(obj, stream) -class JsonDiffSyntax(object): +class JsonDiffSyntax: def emit_set_diff(self, a, b, s, added, removed): raise NotImplementedError() @@ -141,7 +141,7 @@ def unpatch(self, a, d): raise NotImplementedError() -class CompactJsonDiffSyntax(object): +class CompactJsonDiffSyntax: def emit_set_diff(self, a, b, s, added, removed): if s == 0.0 or len(removed) == len(a): return {replace: b} if isinstance(b, dict) else b @@ -230,7 +230,7 @@ def patch(self, a, d): return d -class ExplicitJsonDiffSyntax(object): +class ExplicitJsonDiffSyntax: def emit_set_diff(self, a, b, s, added, removed): if s == 0.0 or len(removed) == len(a): return b @@ -277,7 +277,7 @@ def emit_value_diff(self, a, b, s): return b -class SymmetricJsonDiffSyntax(object): +class SymmetricJsonDiffSyntax: def emit_set_diff(self, a, b, s, added, removed): if s == 0.0 or len(removed) == len(a): return [a, b] @@ -447,9 +447,9 @@ def emit_list_diff(self, a, b, s, inserted, changed, deleted): } -class JsonDiffer(object): +class JsonDiffer: - class Options(object): + class Options: pass def __init__(self, syntax='compact', load=False, dump=False, marshal=False, diff --git a/jsondiff/cli.py b/jsondiff/cli.py index dd066e4..cc5561a 100644 --- a/jsondiff/cli.py +++ b/jsondiff/cli.py @@ -3,7 +3,7 @@ import sys def load_file(serializer, file_path): - with open(file_path, "r") as f: + with open(file_path) as f: parsed = None try: parsed = serializer.deserialize_file(f) diff --git a/jsondiff/symbols.py b/jsondiff/symbols.py index 6e81e3e..7d022b1 100644 --- a/jsondiff/symbols.py +++ b/jsondiff/symbols.py @@ -1,5 +1,4 @@ - -class Symbol(object): +class Symbol: def __init__(self, label): self._label = label diff --git a/tests/generate_readme.py b/tests/generate_readme.py index 56a46cc..76b5604 100644 --- a/tests/generate_readme.py +++ b/tests/generate_readme.py @@ -1,6 +1,5 @@ # this is used for generating the repo front page -from __future__ import print_function def do(cmd, comment=None): if comment: From 006ee23d510d5ad88f34fa7abc21d156fe1aa5dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20K=C5=82oczko?= Date: Sat, 29 Jun 2024 08:27:31 +0000 Subject: [PATCH 2/2] filter all code over ruff as well to drop unused imports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tomasz Kłoczko --- docs/conf.py | 3 --- tests/test_jsondiff.py | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/docs/conf.py b/docs/conf.py index aa799b6..a443731 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -11,9 +11,6 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys -import os -import shlex # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the diff --git a/tests/test_jsondiff.py b/tests/test_jsondiff.py index 9d3a5b5..58ca1ac 100644 --- a/tests/test_jsondiff.py +++ b/tests/test_jsondiff.py @@ -6,7 +6,7 @@ import pytest import jsondiff -from jsondiff import diff, replace, add, discard, insert, delete, update, JsonDiffer +from jsondiff import diff, replace, add, discard, insert, delete, JsonDiffer from .utils import generate_random_json, perturbate_json