diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8549bb9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ + +# Align TOML indenting with Tombi +[*.toml] +indent_size = 2 diff --git a/.github/workflows/pypi-release.yml b/.github/workflows/pypi-release.yml index 8db76da..3f61945 100644 --- a/.github/workflows/pypi-release.yml +++ b/.github/workflows/pypi-release.yml @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # This file is part of Invenio. -# Copyright (C) 2020 CERN. +# Copyright (C) 2020-2025 CERN. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details @@ -15,28 +15,5 @@ on: jobs: Publish: - runs-on: ubuntu-20.04 - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: 3.8 - - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install setuptools wheel - - - name: Build package - run: python setup.py sdist bdist_wheel - - - name: Publish on PyPI - uses: pypa/gh-action-pypi-publish@v1.3.1 - with: - user: __token__ - # The token is provided by the inveniosoftware organization - password: ${{ secrets.pypi_token }} + uses: inveniosoftware/workflows/.github/workflows/pypi-publish.yml@master + secrets: inherit diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index c7cd003..5fe1cc9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,40 +24,5 @@ on: default: 'Manual trigger' jobs: - Tests: - runs-on: ubuntu-20.04 - strategy: - matrix: - python-version: [3.5, 3.6, 3.7, 3.8, 3.9] - requirements-level: [min, pypi] - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - - name: Generate dependencies - run: | - sudo apt-get install libxml2-dev libxslt1-dev - python -m pip install --upgrade pip setuptools py wheel requirements-builder - requirements-builder -e all --level=${{ matrix.requirements-level }} setup.py > .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt - - - name: Cache pip - uses: actions/cache@v2 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('.${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt') }} - - - name: Install dependencies - run: | - pip install -r .${{ matrix.requirements-level }}-${{ matrix.python-version }}-requirements.txt - pip install .[all] - pip freeze - - - name: Run tests - run: | - ./run-tests.sh + Python: + uses: inveniosoftware/workflows/.github/workflows/tests-python.yml@master diff --git a/.gitignore b/.gitignore index 3aca7a5..4a534f5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ docs/_build docs/db docs/static htmlcov +uv.lock diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index c6b08d7..0000000 --- a/MANIFEST.in +++ /dev/null @@ -1,12 +0,0 @@ -# SPDX-FileCopyrightText: 2014, 2016 CERN. -# SPDX-License-Identifier: MIT - -exclude .git-blame-ignore-revs -include README.rst CHANGES CONTRIBUTING.rst AUTHORS LICENSE MANIFEST.in -include RELEASE-NOTES.rst -include .coveragerc pytest.ini -include .lgtm MAINTAINERS -include docs/*.rst docs/*.py docs/Makefile docs/requirements.txt -include *.py *.sh -include tox.ini tests/*.py -recursive-include .github/workflows *.yml diff --git a/dictdiffer/__init__.py b/dictdiffer/__init__.py index debd78a..230ff9b 100644 --- a/dictdiffer/__init__.py +++ b/dictdiffer/__init__.py @@ -5,8 +5,7 @@ """Dictdiffer is a helper module to diff and patch dictionaries.""" -from collections.abc import (Iterable, MutableMapping, MutableSequence, - MutableSet) +from collections.abc import Iterable, MutableMapping, MutableSequence, MutableSet from copy import deepcopy from .utils import EPSILON, PathLimit, are_different, dot_lookup @@ -71,7 +70,7 @@ def diff(first, second, node=None, ignore=None, path_limit=None, expand=False, ... path_limit=PathLimit([('a', 'b')]))) [('add', '', [('a', {})]), ('add', 'a', [('b', 'c')])] - >>> from dictdiffer.utils import PathLimit + >>> from dictdiffer.utils import PathLimit >>> list(diff({'a': {'b': 'c'}}, {'a': {'b': 'c'}}, path_limit=PathLimit([('a',)]))) [] diff --git a/dictdiffer/version.py b/dictdiffer/version.py index b1df833..59a7cfc 100644 --- a/dictdiffer/version.py +++ b/dictdiffer/version.py @@ -1,8 +1,7 @@ -# SPDX-FileCopyrightText: 2014-2021 CERN. -# SPDX-License-Identifier: MIT - +# -*- coding: utf-8 -*- # Do not change the format of this next line. Doing so risks breaking # setup.py and docs/conf.py + """Version information for dictdiffer package.""" -__version__ = '0.9.0' +__version__ = "0.9.0" diff --git a/docs/conf.py b/docs/conf.py index 4df8b04..c86258f 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -19,16 +19,7 @@ import sys -from pkg_resources import get_distribution - -_html_theme = "sphinx_rtd_theme" -_html_theme_path = [] -try: - import sphinx_rtd_theme - _html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] -except ImportError: - print("Template {0} not found, pip install it", file=sys.stderr) - _html_theme = "default" +from dictdiffer import __version__ # 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 @@ -74,10 +65,9 @@ # built documents. # # The short X.Y version. -version = get_distribution('dictdiffer').version # The full version, including alpha/beta/rc tags. -release = version +release = __version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -122,8 +112,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -#html_theme = 'default' -html_theme = _html_theme +html_theme = 'default' # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the @@ -132,7 +121,6 @@ # Add any paths that contain custom themes here, relative to this directory. #html_theme_path = [] -html_theme_path = _html_theme_path # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..e6a711b --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,77 @@ +# SPDX-FileCopyrightText: 2013 Fatih Erikli. +# SPDX-FileCopyrightText: 2014, 2015, 2016 CERN. +# SPDX-FileCopyrightText: 2016 CERN. +# SPDX-FileCopyrightText: 2017, 2019 ETH Zurich, Swiss Data Science Center, Jiri Kuncar. +# SPDX-FileCopyrightText: 2026 TU Wien. +# SPDX-License-Identifier: MIT + +[project] +name = "dictdiffer" +description = "Dictdiffer is a library that helps you to diff and patch dictionaries." +readme = "README.rst" +requires-python = ">=3.7" +license = "MIT" +authors = [ + { name = "Invenio Collaboration", email = "info@inveniosoftware.org" }, +] +classifiers = [ + "Development Status :: 5 - Production/Stable", + "Intended Audience :: Developers", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Programming Language :: Python :: 3.8", + "Programming Language :: Python :: 3.9", + "Topic :: Utilities", +] +dynamic = ["version"] + +[project.urls] +Changelog = "https://github.com/inveniosoftware/dictdiffer/blob/master/CHANGES" +Docs = "https://dictdiffer.rtfd.io/" +Homepage = "https://github.com/inveniosoftware/dictdiffer" + +[project.optional-dependencies] +docs = [ + "sphinx-rtd-theme>=0.2", + "sphinx>=3", +] +numpy = [ + "numpy>=1.20.0", +] +tests = [ + "mock>=1.3.0", + "pycodestyle>=2.10.0", + "pytest-cov>=2.10.1", + "pytest-isort>=1.2.0", + "pytest-pydocstyle>=2.2.0", + "pytest>=6,<9", + "sphinx>=3", + "tox>=3.7.0", +] + +[build-system] +requires = ["hatch-vcs", "hatchling"] +build-backend = "hatchling.build" + +[tool.hatch.version] +path = "dictdiffer/version.py" + +[tool.hatch.build.targets.sdist] +include = [ + "/dictdiffer", +] + +[tool.isort] +profile = "black" + +[tool.pydocstyle] +add_ignore = "" + +[tool.pytest.ini_options] +addopts = '--isort --pydocstyle --doctest-glob="*.rst" --doctest-modules --cov=dictdiffer --cov-report=term-missing' +testpaths = "tests dictdiffer" +live_server_scope = "module" diff --git a/pytest.ini b/pytest.ini deleted file mode 100644 index 7f89147..0000000 --- a/pytest.ini +++ /dev/null @@ -1,7 +0,0 @@ -# SPDX-FileCopyrightText: 2014, 2016 CERN. -# SPDX-License-Identifier: MIT - -[pytest] -addopts = --isort --pydocstyle --pycodestyle --doctest-glob="*.rst" --doctest-modules --cov=dictdiffer --cov-report=term-missing -testpaths = tests dictdiffer -filterwarnings = ignore::pytest.PytestDeprecationWarning diff --git a/run-tests.sh b/run-tests.sh index b360946..86d3e2e 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -10,7 +10,7 @@ set -o errexit # Quit on unbound symbols set -o nounset -python -m check_manifest --ignore ".*-requirements.txt" python -m sphinx.cmd.build -qnNW docs docs/_build/html python -m pytest python -m sphinx.cmd.build -qnNW -b doctest docs docs/_build/doctest +pycodestyle --ignore=E501,E226,W504 dictdiffer diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 05ddca3..0000000 --- a/setup.cfg +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-FileCopyrightText: 2016 CERN. -# SPDX-License-Identifier: MIT - -[aliases] -test = pytest - -[build_sphinx] -source-dir = docs/ -build-dir = docs/_build -all_files = 1 - -[bdist_wheel] -universal = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index e7dd20a..0000000 --- a/setup.py +++ /dev/null @@ -1,105 +0,0 @@ -# SPDX-FileCopyrightText: 2013 Fatih Erikli. -# SPDX-FileCopyrightText: 2014, 2015, 2016 CERN. -# SPDX-FileCopyrightText: 2017, 2019 ETH Zurich, Swiss Data Science Center, Jiri Kuncar. -# SPDX-License-Identifier: MIT - -"""Dictdiffer is a library that helps you to diff and patch dictionaries.""" - -from __future__ import absolute_import, print_function - -import os - -from setuptools import find_packages, setup - -readme = open('README.rst').read() - -tests_require = [ - 'check-manifest>=0.42', - 'mock>=1.3.0', - 'pytest==5.4.3;python_version<="3.5"', - 'pytest>=6;python_version>"3.5"', - 'pytest-cov>=2.10.1', - 'pytest-isort>=1.2.0', - 'pytest-pycodestyle>=2;python_version<="3.5"', - 'pytest-pycodestyle>=2.2.0;python_version>"3.5"', - 'pytest-pydocstyle>=2;python_version<="3.5"', - 'pytest-pydocstyle>=2.2.0;python_version>"3.5"', - 'sphinx>=3', - 'tox>=3.7.0', -] - -extras_require = { - 'docs': [ - 'Sphinx>=3', - 'sphinx-rtd-theme>=0.2', - ], - 'numpy': [ - 'numpy>=1.13.0;python_version<"3.7"', - 'numpy>=1.15.0;python_version<"3.8"', - 'numpy>=1.18.0;python_version<"3.9"', - 'numpy>=1.20.0;python_version>="3.9"', - ], - 'tests': tests_require, -} - -extras_require['all'] = [] -for key, reqs in extras_require.items(): - if ':' == key[0]: - continue - extras_require['all'].extend(reqs) - -setup_requires = [ - 'pytest-runner>=2.7', - 'setuptools_scm>=3.1.0', -] - -packages = find_packages() - -version_template = """\ -# -*- coding: utf-8 -*- -# Do not change the format of this next line. Doing so risks breaking -# setup.py and docs/conf.py -\"\"\"Version information for dictdiffer package.\"\"\" - -__version__ = {version!r} -""" - -setup( - name='dictdiffer', - use_scm_version={ - 'local_scheme': 'dirty-tag', - 'write_to': os.path.join('dictdiffer', 'version.py'), - 'write_to_template': version_template, - }, - description=__doc__, - long_description=readme, - author='Invenio Collaboration', - author_email='info@inveniosoftware.org', - url='https://github.com/inveniosoftware/dictdiffer', - project_urls={ - 'Changelog': ( - 'https://github.com/inveniosoftware/dictdiffer' - '/blob/master/CHANGES' - ), - 'Docs': 'https://dictdiffer.rtfd.io/', - }, - packages=['dictdiffer'], - zip_safe=False, - python_requires='>=3.5', - extras_require=extras_require, - setup_requires=setup_requires, - tests_require=tests_require, - classifiers=[ - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Programming Language :: Python :: 3.7', - 'Programming Language :: Python :: 3.8', - 'Programming Language :: Python :: 3.9', - 'Development Status :: 5 - Production/Stable', - 'Intended Audience :: Developers', - 'License :: OSI Approved :: MIT License', - 'Operating System :: OS Independent', - 'Topic :: Utilities', - ], -) diff --git a/tests/test_resolve.py b/tests/test_resolve.py index 9cc36c5..6926acd 100644 --- a/tests/test_resolve.py +++ b/tests/test_resolve.py @@ -4,8 +4,11 @@ import unittest from dictdiffer.conflict import Conflict -from dictdiffer.resolve import (NoFurtherResolutionException, Resolver, - UnresolvedConflictsException) +from dictdiffer.resolve import ( + NoFurtherResolutionException, + Resolver, + UnresolvedConflictsException, +) class UnresolvedConflictsExceptionTest(unittest.TestCase): diff --git a/tests/test_utils.py b/tests/test_utils.py index 8f9c444..fd2cbd9 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -3,8 +3,15 @@ import unittest -from dictdiffer.utils import (PathLimit, WildcardDict, create_dotted_node, - dot_lookup, get_path, is_super_path, nested_hash) +from dictdiffer.utils import ( + PathLimit, + WildcardDict, + create_dotted_node, + dot_lookup, + get_path, + is_super_path, + nested_hash, +) class UtilsTest(unittest.TestCase): diff --git a/tox.ini b/tox.ini deleted file mode 100644 index f860c35..0000000 --- a/tox.ini +++ /dev/null @@ -1,14 +0,0 @@ -# SPDX-FileCopyrightText: 2014 CERN. -# SPDX-FileCopyrightText: 2017 ETH Zurich, Swiss Data Science Center, Jiri Kuncar. -# SPDX-License-Identifier: MIT - -[tox] -envlist = py35, py36, py37, py38, py39 - -[testenv] -extras = numpy, tests -commands = - {envpython} -m check_manifest --ignore ".*-requirements.txt" - {envpython} -m sphinx.cmd.build -qnNW docs docs/_build/html - {envpython} setup.py test - {envpython} -m sphinx.cmd.build -qnNW -b doctest docs docs/_build/doctest