Skip to content

Commit

Permalink
global: drop support for Python<3.5 (#160)
Browse files Browse the repository at this point in the history
* Drop support for Python<3.5.

* Add py35 and py39 to test matrix.

* Fix warning and remove pytest-invenio dependency.
  • Loading branch information
adrien-berchet authored Jul 20, 2021
1 parent 0244647 commit fb2064a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
requirements-level: [min, pypi]

steps:
Expand Down
10 changes: 5 additions & 5 deletions dictdiffer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

"""Dictdiffer is a helper module to diff and patch dictionaries."""

from collections.abc import (Iterable, MutableMapping, MutableSequence,
MutableSet)
from copy import deepcopy

from ._compat import (PY2, Iterable, MutableMapping, MutableSequence,
MutableSet, string_types, text_type)
from .utils import EPSILON, PathLimit, are_different, dot_lookup
from .version import __version__

Expand Down Expand Up @@ -128,7 +128,7 @@ def _process_ignore_value(value):
return value,
elif isinstance(value, list):
return tuple(value)
elif not dot_notation and isinstance(value, string_types):
elif not dot_notation and isinstance(value, str):
return value,
return value

Expand All @@ -137,7 +137,7 @@ def _process_ignore_value(value):
def dotted(node, default_type=list):
"""Return dotted notation."""
if dot_notation and \
all(map(lambda x: isinstance(x, string_types) and '.' not in x,
all(map(lambda x: isinstance(x, str) and '.' not in x,
node)):
return '.'.join(node)
else:
Expand Down Expand Up @@ -299,7 +299,7 @@ def add(node, changes):

def change(node, changes):
dest = dot_lookup(destination, node, parent=True)
if isinstance(node, string_types):
if isinstance(node, str):
last_node = node.split('.')[-1]
else:
last_node = node[-1]
Expand Down
31 changes: 0 additions & 31 deletions dictdiffer/_compat.py

This file was deleted.

12 changes: 6 additions & 6 deletions dictdiffer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"""Utils gathers helper functions, classes for the dictdiffer module."""

import sys
from itertools import zip_longest

from ._compat import izip_longest, num_types, string_types

num_types = int, float
EPSILON = sys.float_info.epsilon


Expand Down Expand Up @@ -156,7 +156,7 @@ def create_dotted_node(node):
>>> create_dotted_node( ['foo', 'bar', 'baz'] )
'foo.bar.baz'
"""
if all(map(lambda x: isinstance(x, string_types), node)):
if all(map(lambda x: isinstance(x, str), node)):
return '.'.join(node)
else:
return list(node)
Expand All @@ -165,7 +165,7 @@ def create_dotted_node(node):
def get_path(patch):
"""Return the path for a given dictdiffer.diff patch."""
if patch[1] != '':
keys = (patch[1].split('.') if isinstance(patch[1], string_types)
keys = (patch[1].split('.') if isinstance(patch[1], str)
else patch[1])
else:
keys = []
Expand All @@ -189,7 +189,7 @@ def is_super_path(path1, path2):
False
"""
return all(map(lambda x: x[0] == x[1] or x[0] is None,
izip_longest(path1, path2)))
zip_longest(path1, path2)))


def nested_hash(obj):
Expand Down Expand Up @@ -235,7 +235,7 @@ def dot_lookup(source, lookup, parent=False):
return source

value = source
if isinstance(lookup, string_types):
if isinstance(lookup, str):
keys = lookup.split('.')
elif isinstance(lookup, list):
keys = lookup
Expand Down
17 changes: 12 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,23 @@
from __future__ import absolute_import, print_function

import os
import re

from setuptools import find_packages, setup

readme = open('README.rst').read()

tests_require = [
'pytest-invenio>=1.4.0',
'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',
]

Expand Down Expand Up @@ -86,13 +94,12 @@
setup_requires=setup_requires,
tests_require=tests_require,
classifiers=[
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'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',
Expand Down
3 changes: 1 addition & 2 deletions tests/test_dictdiffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
# details.

import unittest
from collections import OrderedDict
from collections import MutableMapping, MutableSequence, OrderedDict

import pytest

from dictdiffer import HAS_NUMPY, diff, dot_lookup, patch, revert, swap
from dictdiffer._compat import MutableMapping, MutableSequence, MutableSet
from dictdiffer.utils import PathLimit


Expand Down
12 changes: 7 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
# details.

[tox]
envlist = py27, py34, py35, py36
envlist = py35, py36, py37, py38, py39

[testenv]
deps = pytest
pytest-cov
pytest-pep8
commands = {envpython} setup.py test
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

0 comments on commit fb2064a

Please sign in to comment.