Skip to content

Commit dffbc3d

Browse files
committed
Merge branch 'release-1.0.0' into master
2 parents 1c46efc + 1ad5c0e commit dffbc3d

13 files changed

+49
-152
lines changed

.github/workflows/run-tests.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Run Tests
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
build:
@@ -9,12 +9,12 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ubuntu-latest]
12-
python-version: [2.7, 3.5, 3.6, 3.7, 3.8]
12+
python-version: [3.7, 3.8, 3.9, "3.10"]
1313

1414
steps:
1515
- uses: actions/checkout@v2
1616
- name: Set up Python ${{ matrix.python-version }}
17-
uses: actions/setup-python@v1
17+
uses: actions/setup-python@v2
1818
with:
1919
python-version: ${{ matrix.python-version }}
2020
- name: Install dependencies
@@ -25,4 +25,4 @@ jobs:
2525
pip install dist/*.whl
2626
- name: Test with pytest
2727
run: |
28-
cd tests/ && nosetests --with-coverage --cover-package jmespath .
28+
cd tests/ && py.test --cov jmespath --cov-report term-missing

.travis.yml

-30
This file was deleted.

README.rst

-8
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@ JMESPath
66
:target: https://gitter.im/jmespath/chat
77

88

9-
.. image:: https://travis-ci.org/jmespath/jmespath.py.svg?branch=develop
10-
:target: https://travis-ci.org/jmespath/jmespath.py
11-
12-
13-
.. image:: https://codecov.io/github/jmespath/jmespath.py/coverage.svg?branch=develop
14-
:target: https://codecov.io/github/jmespath/jmespath.py?branch=develop
15-
16-
179
JMESPath (pronounced "james path") allows you to declaratively specify how to
1810
extract elements from a JSON document.
1911

docs/conf.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
# The short X.Y version.
3939
version = '0.8'
4040
# The full version, including alpha/beta/rc tags.
41-
release = '0.10.0'
41+
release = '1.0.0'
4242

4343
# The language for content autogenerated by Sphinx. Refer to documentation
4444
# for a list of supported languages.

jmespath/__init__.py

+1-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
1-
import warnings
2-
import sys
31
from jmespath import parser
42
from jmespath.visitor import Options
53

6-
__version__ = '0.10.0'
7-
8-
9-
if sys.version_info[:2] <= (2, 6) or ((3, 0) <= sys.version_info[:2] <= (3, 3)):
10-
python_ver = '.'.join(str(x) for x in sys.version_info[:3])
11-
12-
warnings.warn(
13-
'You are using Python {0}, which will no longer be supported in '
14-
'version 0.11.0'.format(python_ver),
15-
DeprecationWarning)
4+
__version__ = '1.0.0'
165

176

187
def compile(expression):

jmespath/compat.py

+11-57
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,19 @@
11
import sys
22
import inspect
3+
from itertools import zip_longest
34

4-
PY2 = sys.version_info[0] == 2
55

6+
text_type = str
7+
string_type = str
68

7-
def with_metaclass(meta, *bases):
8-
# Taken from flask/six.
9-
class metaclass(meta):
10-
def __new__(cls, name, this_bases, d):
11-
return meta(name, bases, d)
12-
return type.__new__(metaclass, 'temporary_class', (), {})
139

10+
def with_str_method(cls):
11+
# In python3, we don't need to do anything, we return a str type.
12+
return cls
1413

15-
if PY2:
16-
text_type = unicode
17-
string_type = basestring
18-
from itertools import izip_longest as zip_longest
14+
def with_repr_method(cls):
15+
return cls
1916

20-
def with_str_method(cls):
21-
"""Class decorator that handles __str__ compat between py2 and py3."""
22-
# In python2, the __str__ should be __unicode__
23-
# and __str__ should return bytes.
24-
cls.__unicode__ = cls.__str__
25-
def __str__(self):
26-
return self.__unicode__().encode('utf-8')
27-
cls.__str__ = __str__
28-
return cls
29-
30-
def with_repr_method(cls):
31-
"""Class decorator that handle __repr__ with py2 and py3."""
32-
# This is almost the same thing as with_str_method *except*
33-
# it uses the unicode_escape encoding. This also means we need to be
34-
# careful encoding the input multiple times, so we only encode
35-
# if we get a unicode type.
36-
original_repr_method = cls.__repr__
37-
def __repr__(self):
38-
original_repr = original_repr_method(self)
39-
if isinstance(original_repr, text_type):
40-
original_repr = original_repr.encode('unicode_escape')
41-
return original_repr
42-
cls.__repr__ = __repr__
43-
return cls
44-
45-
def get_methods(cls):
46-
for name, method in inspect.getmembers(cls,
47-
predicate=inspect.ismethod):
48-
yield name, method
49-
50-
else:
51-
text_type = str
52-
string_type = str
53-
from itertools import zip_longest
54-
55-
def with_str_method(cls):
56-
# In python3, we don't need to do anything, we return a str type.
57-
return cls
58-
59-
def with_repr_method(cls):
60-
return cls
61-
62-
def get_methods(cls):
63-
for name, method in inspect.getmembers(cls,
64-
predicate=inspect.isfunction):
65-
yield name, method
17+
def get_methods(cls):
18+
for name, method in inspect.getmembers(cls, predicate=inspect.isfunction):
19+
yield name, method

jmespath/functions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from jmespath import exceptions
55
from jmespath.compat import string_type as STRING_TYPE
6-
from jmespath.compat import get_methods, with_metaclass
6+
from jmespath.compat import get_methods
77

88

99
# python types -> jmespath types
@@ -64,7 +64,7 @@ def _populate_function_table(cls):
6464
cls.FUNCTION_TABLE = function_table
6565

6666

67-
class Functions(with_metaclass(FunctionRegistry, object)):
67+
class Functions(metaclass=FunctionRegistry):
6868

6969
FUNCTION_TABLE = {
7070
}

requirements.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
nose==1.2.1
2-
py==1.4.12
3-
tox==1.4.2
41
wheel==0.24.0
5-
coverage==5.0.3 ; python_version == '3.8'
6-
coverage==3.7.1 ; python_version != '3.8'
7-
hypothesis==3.1.0 ; python_version != '3.8'
2+
pytest==6.2.5 ; python_version >= '3.6'
3+
pytest<5.0 ; python_version < '3.6'
4+
pytest-cov==3.0.0 ; python_version >= '3.6'
5+
pytest-cov<3.0.0 ; python_version < '3.6'
6+
hypothesis==3.1.0 ; python_version < '3.8'
87
hypothesis==5.5.4 ; python_version == '3.8'
8+
hypothesis==5.35.4 ; python_version == '3.9'

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bdist_wheel]
2-
universal = 1
2+
universal = 0
33

44
[metadata]
55
license_file = LICENSE.txt

setup.py

+4-20
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,13 @@
11
#!/usr/bin/env python
22

33
import io
4-
import sys
5-
import warnings
64

75
from setuptools import setup, find_packages
86

97

10-
if sys.version_info[:2] <= (2, 6) or ((3, 0) <= sys.version_info[:2] <= (3, 3)):
11-
python_ver = '.'.join(str(x) for x in sys.version_info[:3])
12-
13-
warnings.warn(
14-
'You are using Python {0}, which will no longer be supported in '
15-
'version 0.11.0'.format(python_ver),
16-
DeprecationWarning)
17-
18-
198
setup(
209
name='jmespath',
21-
version='0.10.0',
10+
version='1.0.0',
2211
description='JSON Matching Expressions',
2312
long_description=io.open('README.rst', encoding='utf-8').read(),
2413
author='James Saryerwinnie',
@@ -27,22 +16,17 @@
2716
scripts=['bin/jp.py'],
2817
packages=find_packages(exclude=['tests']),
2918
license='MIT',
30-
python_requires='>=2.6, !=3.0.*, !=3.1.*, !=3.2.*',
19+
python_requires='>=3.7',
3120
classifiers=[
3221
'Development Status :: 5 - Production/Stable',
3322
'Intended Audience :: Developers',
3423
'Natural Language :: English',
3524
'License :: OSI Approved :: MIT License',
3625
'Programming Language :: Python',
37-
'Programming Language :: Python :: 2',
38-
'Programming Language :: Python :: 2.6',
39-
'Programming Language :: Python :: 2.7',
4026
'Programming Language :: Python :: 3',
41-
'Programming Language :: Python :: 3.3',
42-
'Programming Language :: Python :: 3.4',
43-
'Programming Language :: Python :: 3.5',
44-
'Programming Language :: Python :: 3.6',
4527
'Programming Language :: Python :: 3.7',
28+
'Programming Language :: Python :: 3.8',
29+
'Programming Language :: Python :: 3.9',
4630
'Programming Language :: Python :: Implementation :: CPython',
4731
'Programming Language :: Python :: Implementation :: PyPy',
4832
],

tests/test_compliance.py

+17-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from tests import OrderedDict
44
from tests import json
55

6-
from nose.tools import assert_equal
6+
import pytest
77

88
from jmespath.visitor import Options
99

@@ -15,19 +15,19 @@
1515
OPTIONS = Options(dict_cls=OrderedDict)
1616

1717

18-
def test_compliance():
18+
def _compliance_tests(requested_test_type):
1919
for full_path in _walk_files():
2020
if full_path.endswith('.json'):
2121
for given, test_type, test_data in load_cases(full_path):
2222
t = test_data
2323
# Benchmark tests aren't run as part of the normal
2424
# test suite, so we only care about 'result' and
2525
# 'error' test_types.
26-
if test_type == 'result':
27-
yield (_test_expression, given, t['expression'],
26+
if test_type == 'result' and test_type == requested_test_type:
27+
yield (given, t['expression'],
2828
t['result'], os.path.basename(full_path))
29-
elif test_type == 'error':
30-
yield (_test_error_expression, given, t['expression'],
29+
elif test_type == 'error' and test_type == requested_test_type:
30+
yield (given, t['expression'],
3131
t['error'], os.path.basename(full_path))
3232

3333

@@ -63,7 +63,11 @@ def load_cases(full_path):
6363
yield (given, test_type, case)
6464

6565

66-
def _test_expression(given, expression, expected, filename):
66+
@pytest.mark.parametrize(
67+
'given, expression, expected, filename',
68+
_compliance_tests('result')
69+
)
70+
def test_expression(given, expression, expected, filename):
6771
import jmespath.parser
6872
try:
6973
parsed = jmespath.compile(expression)
@@ -80,10 +84,14 @@ def _test_expression(given, expression, expected, filename):
8084
actual_repr, pformat(parsed.parsed),
8185
json.dumps(given, indent=4)))
8286
error_msg = error_msg.replace(r'\n', '\n')
83-
assert_equal(actual, expected, error_msg)
87+
assert actual == expected, error_msg
8488

8589

86-
def _test_error_expression(given, expression, error, filename):
90+
@pytest.mark.parametrize(
91+
'given, expression, error, filename',
92+
_compliance_tests('error')
93+
)
94+
def test_error_expression(given, expression, error, filename):
8795
import jmespath.parser
8896
if error not in ('syntax', 'invalid-type',
8997
'unknown-function', 'invalid-arity', 'invalid-value'):

tests/test_lexer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def test_bad_first_character(self):
152152
tokens = list(self.lexer.tokenize('^foo[0]'))
153153

154154
def test_unknown_character_with_identifier(self):
155-
with self.assertRaisesRegexp(LexerError, "Unknown token"):
155+
with self.assertRaisesRegex(LexerError, "Unknown token"):
156156
list(self.lexer.tokenize('foo-bar'))
157157

158158

tests/test_parser.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def test_bad_unicode_string(self):
169169
error_message = re.compile(
170170
r'Bad jmespath expression: '
171171
r'Invalid \\uXXXX escape.*\\uAZ12', re.DOTALL)
172-
with self.assertRaisesRegexp(exceptions.LexerError, error_message):
172+
with self.assertRaisesRegex(exceptions.LexerError, error_message):
173173
self.parser.parse(r'"\uAZ12"')
174174

175175

0 commit comments

Comments
 (0)