Skip to content

Commit dc3219b

Browse files
authored
release 0.3.62 (#341)
1 parent 9522954 commit dc3219b

10 files changed

Lines changed: 40 additions & 64 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
# Version 0.3.62
4+
5+
* Migrate to pyparsing 3.x and drop Python 2.7 support (@alejandrorm) [#337]
6+
37
# Version 0.3.61
48

59
* fix(tox): remove old EOLed python 3.x versions, added new python versions (@pierresouchay) [#330]

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,7 @@ assert config == d
393393
- Carol Guo ([@carolguo-dd](https://github.com/carolguo-dd))
394394
- Jakub Kubík ([@M0dEx](https://github.com/M0dEx))
395395
- Jakub Szewczyk ([@jakub-szewczyk-exa](https://github.com/jakub-szewczyk-exa))
396+
- Alejandro Rodriguez-Morantes ([@alejandrorm](https://github.com/alejandrorm))
396397

397398
### Thanks
398399

@@ -408,4 +409,4 @@ assert config == d
408409
- Dominik1123 ([@Dominik1123](https://github.com/Dominik1123))
409410
- Richard Taylor ([@richard534](https://github.com/richard534))
410411
- Sergii Lutsanych ([@sergii1989](https://github.com/sergii1989))
411-
412+
- Romain G ([@Romain-DE](https://github.com/Romain-DE))

pyhocon/config_parser.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ def fixed_get_attr(self, item):
2626
except KeyError:
2727
return ""
2828

29-
3029
pyparsing.ParseResults.__getattr__ = fixed_get_attr
3130

3231
from pyhocon.config_tree import (ConfigInclude, ConfigList, ConfigQuotedString,
@@ -50,6 +49,7 @@ def find_package_dirs(name):
5049
raise ImportError('No module named {!r}'.format(name))
5150
return spec.submodule_search_locations
5251

52+
5353
logger = logging.getLogger(__name__)
5454

5555

@@ -350,7 +350,7 @@ def set_default_white_spaces():
350350
false_expr = Keyword("false", case_insensitive=True).set_parse_action(replace_with(False))
351351
null_expr = Keyword("null", case_insensitive=True).set_parse_action(replace_with(NoneValue()))
352352
key = QuotedString('"""', esc_char='\\', unquote_results=False) | \
353-
QuotedString('"', esc_char='\\', unquote_results=False) | Word(alphanums + alphas8bit + '._- /')
353+
QuotedString('"', esc_char='\\', unquote_results=False) | Word(alphanums + alphas8bit + '._- /')
354354

355355
eol = Word('\n\r').suppress()
356356
eol_comma = Word('\n\r,').suppress()
@@ -377,15 +377,16 @@ def set_default_white_spaces():
377377
value_expr = get_period_expr() | number_expr | true_expr | false_expr | null_expr | string_expr
378378

379379
include_content = (
380-
quoted_string | ((Keyword('url') | Keyword('file') | Keyword('package')) - Literal(
381-
'(').suppress() - quoted_string - Literal(')').suppress())
380+
quoted_string | ((Keyword('url') | Keyword('file') | Keyword('package'))
381+
- Literal('(').suppress() - quoted_string
382+
- Literal(')').suppress())
382383
)
383384
include_expr = (
384-
Keyword("include", case_insensitive=True).suppress() + (
385+
Keyword("include", case_insensitive=True).suppress() + (
385386
include_content | (
386-
Keyword("required") - Literal('(').suppress() - include_content - Literal(')').suppress()
387-
)
388-
)
387+
Keyword("required") - Literal('(').suppress() - include_content - Literal(')').suppress()
388+
)
389+
)
389390
).set_parse_action(include_config)
390391

391392
root_dict_expr = Forward()
@@ -407,19 +408,20 @@ def set_default_white_spaces():
407408
# special case when we have a value assignment where the string can potentially be the remainder of the line
408409
assign_expr << Group(
409410
key - ZeroOrMore(comment_no_comma_eol) - (
410-
dict_expr | (Literal('=') | Literal(':') | Literal('+=')) - ZeroOrMore(
411-
comment_no_comma_eol) - ConcatenatedValueParser(multi_value_expr))
411+
dict_expr | (Literal('=') | Literal(':') | Literal('+=')) - ZeroOrMore(
412+
comment_no_comma_eol) - ConcatenatedValueParser(multi_value_expr))
412413
)
413414

414415
# the file can be { ... } where {} can be omitted or []
415416
config_expr = ZeroOrMore(comment_eol | eol) + (
416-
list_expr | root_dict_expr | inside_root_dict_expr) + ZeroOrMore(
417+
list_expr | root_dict_expr | inside_root_dict_expr
418+
) + ZeroOrMore(
417419
comment_eol | eol_comma)
418420
config = config_expr.parse_string(content, parse_all=True)[0]
419421

420422
if resolve:
421-
allow_unresolved = resolve and unresolved_value is not DEFAULT_SUBSTITUTION \
422-
and unresolved_value is not MANDATORY_SUBSTITUTION
423+
allow_unresolved = resolve and unresolved_value is not DEFAULT_SUBSTITUTION
424+
allow_unresolved = allow_unresolved and unresolved_value is not MANDATORY_SUBSTITUTION
423425
has_unresolved = cls.resolve_substitutions(config, allow_unresolved)
424426
if has_unresolved and unresolved_value is MANDATORY_SUBSTITUTION:
425427
raise ConfigSubstitutionException(
@@ -535,8 +537,8 @@ def _do_substitute(cls, substitution, resolved_value, is_optional_resolved=True)
535537
# if it is a string, then add the extra ws that was present in the original string after the substitution
536538
formatted_resolved_value = resolved_value \
537539
if resolved_value is None \
538-
or isinstance(resolved_value, (dict, list)) \
539-
or substitution.index == len(config_values.tokens) - 1 \
540+
or isinstance(resolved_value, (dict, list)) \
541+
or substitution.index == len(config_values.tokens) - 1 \
540542
else (str(resolved_value) + substitution.ws)
541543
# use a deepcopy of resolved_value to avoid mutation
542544
config_values.put(substitution.index, copy.deepcopy(formatted_resolved_value))
@@ -606,11 +608,11 @@ def resolve_substitutions(cls, config, accept_unresolved=False):
606608

607609
is_optional_resolved, resolved_value = cls._resolve_variable(config, substitution)
608610

609-
if isinstance(resolved_value, ConfigValues) :
611+
if isinstance(resolved_value, ConfigValues):
610612
resolved_value = resolved_value.transform()
611613
value_to_be_substitute = resolved_value
612614
if overridden_value and not isinstance(overridden_value, ConfigValues):
613-
value_to_be_substitute = overridden_value
615+
value_to_be_substitute = overridden_value
614616
unresolved, _, _ = cls._do_substitute(substitution, value_to_be_substitute, is_optional_resolved)
615617

616618
any_unresolved = unresolved or any_unresolved

pyhocon/converter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,3 @@ def _escape_match(cls, match):
284284
@classmethod
285285
def _escape_string(cls, string):
286286
return re.sub(r'[\x00-\x1F"\\]', cls._escape_match, string)
287-

pyhocon/period_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def get_period_expr():
6262
# Allow only spaces as a valid separator between value and unit.
6363
# E.g. \t as a separator is invalid: '10<TAB>weeks'.
6464
return Combine(
65-
Word(nums)('value') + ZeroOrMore(Literal(" ")).suppress() + Or(period_types)('unit') + WordEnd(
66-
alphanums).suppress()
65+
Word(nums)('value') + ZeroOrMore(Literal(" ")).suppress() + Or(period_types)('unit') + WordEnd(
66+
alphanums).suppress()
6767
).set_parse_action(convert_period)
6868

6969

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[flake8]
2-
ignore =
2+
ignore = W503
33
max-line-length = 160
44
statistics = True
55
count = True

setup.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,10 @@
11
#!/usr/bin/env python
22

3-
import sys
4-
53
from setuptools import setup
6-
from setuptools.command.test import test as TestCommand
7-
8-
9-
class PyTestCommand(TestCommand):
10-
user_options = [('pytest-args=', 'a', "Arguments to pass to py.test")]
11-
12-
def initialize_options(self):
13-
TestCommand.initialize_options(self)
14-
self.pytest_args = []
15-
16-
def finalize_options(self):
17-
TestCommand.finalize_options(self)
18-
self.test_args = []
19-
self.test_suite = True
20-
21-
def run_tests(self):
22-
import pytest
23-
errno = pytest.main(self.pytest_args)
24-
sys.exit(errno)
25-
264

275
setup(
286
name='pyhocon',
29-
version='0.3.61',
7+
version='0.3.62',
308
description='HOCON parser for Python',
319
long_description='pyhocon is a HOCON parser for Python. Additionally we provide a tool (pyhocon) to convert any HOCON '
3210
'content into json, yaml and properties format.',
@@ -56,14 +34,9 @@ def run_tests(self):
5634
extras_require={
5735
'Duration': ['python-dateutil>=2.8.0']
5836
},
59-
tests_require=['pytest', 'mock==3.0.5'],
6037
entry_points={
6138
'console_scripts': [
6239
'pyhocon=pyhocon.tool:main'
6340
]
64-
},
65-
test_suite='tests',
66-
cmdclass={
67-
'test': PyTestCommand
6841
}
6942
)

tests/test_config_parser.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
except Exception:
2929
from datetime import timedelta as period
3030

31+
3132
class TestConfigParser(object):
3233
def test_parse_simple_value(self):
3334
config = ConfigFactory.parse_string(
@@ -118,7 +119,6 @@ def test_parse_with_enclosing_brace_and_period_like_value(self):
118119
assert config.get_string('a.b') == '5'
119120
assert config.get_string('a.y_min') == '42'
120121

121-
122122
def test_issue_324(self):
123123
config = ConfigFactory.parse_string("a { c = 3\nd = 4 }")
124124
assert config["a"]["c"] == 3
@@ -194,11 +194,10 @@ def test_parse_with_list_mixed_types_with_durations_and_trailing_comma(self):
194194
# Depending if parsing dates is enabled, might parse date or might not
195195
# since this is an optional dependency
196196
assert (
197-
config['b'] == ['a', 1, period(weeks=10), period(minutes=5)]
198-
) or (
199-
config['b'] == ['a', 1, '10 weeks', '5 minutes']
200-
)
201-
197+
config['b'] == ['a', 1, period(weeks=10), period(minutes=5)]
198+
) or (
199+
config['b'] == ['a', 1, '10 weeks', '5 minutes']
200+
)
202201

203202
def test_parse_with_enclosing_square_bracket(self):
204203
config = ConfigFactory.parse_string("[1, 2, 3]")
@@ -1757,12 +1756,11 @@ def test_override_optional_substitution(self):
17571756
result = ${test}
17581757
""")
17591758
assert config == {
1760-
'a' : 3,
1759+
'a': 3,
17611760
'test': 3,
17621761
'result': 3
17631762
}
17641763

1765-
17661764
def test_substitution_cycle(self):
17671765
with pytest.raises(ConfigSubstitutionException):
17681766
ConfigFactory.parse_string(
@@ -2701,7 +2699,6 @@ def test_triple_quotes_keys_triple_quotes_values_second_separator(self):
27012699
try:
27022700
from dateutil.relativedelta import relativedelta
27032701

2704-
27052702
@pytest.mark.parametrize('data_set', [
27062703
('a: 1 months', relativedelta(months=1)),
27072704
('a: 1months', relativedelta(months=1)),

tests/test_periods.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def test_parse_string_with_duration(data_set):
6262
try:
6363
from dateutil.relativedelta import relativedelta
6464

65-
6665
@pytest.mark.parametrize('data_set', [
6766
('1 months', relativedelta(months=1)),
6867
('1months', relativedelta(months=1)),
@@ -82,7 +81,6 @@ def test_parse_string_with_duration_optional_units(data_set):
8281

8382
assert parsed == data_set[1]
8483

85-
8684
def test_format_relativedelta():
8785

8886
for time_delta, expected_result in ((relativedelta(seconds=0), '0 seconds'),

tox.ini

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@
22
envlist = flake8, py{37,38,39,310,311,312,313}
33

44
[testenv]
5-
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
5+
passenv = TRAVIS,TRAVIS_JOB_ID,TRAVIS_BRANCH
66
deps =
77
pytest
88
coveralls
9+
setuptools
10+
mock
911
python-dateutil>=2.8.0
12+
PyYAML
1013
# for python 3.4
1114
typing
1215
commands =
13-
coverage run --source=pyhocon setup.py test
16+
coverage run --source=pyhocon -m pytest tests
1417
coverage report -m
15-
coveralls
1618

1719
[testenv:flake8]
1820
basepython = python

0 commit comments

Comments
 (0)