From e28e1bf5cfe73ecb6aa918da46c494af95dac44f Mon Sep 17 00:00:00 2001 From: Anthony Lannutti Date: Fri, 8 Mar 2024 05:33:06 -0600 Subject: [PATCH] chore!: update pyparsing and pyhocon (#145) This PR was originally intended to just update pyparsing but it appears that in order to do that, I also have to update pyhocon. The upgrade went relatively smoothly however I did have to slightly modify a single test that utilizes pyhocon. I'm not super familiar with HOCON but the fact that a space inserted before the newline character fixes the broken test seems to suggest that there is a bug with pyhocon itself. The test in question can be found [here](https://github.com/zifeo/dataconf/commit/80760806e647525a59d4b036816c4907eee96671). --- dataconf/utils.py | 3 +-- poetry.lock | 23 +++++++++++++---------- pyproject.toml | 4 ++-- tests/test_multi.py | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/dataconf/utils.py b/dataconf/utils.py index 833357a..1be74ad 100644 --- a/dataconf/utils.py +++ b/dataconf/utils.py @@ -200,8 +200,7 @@ def __parse(value: any, clazz: Type, path: str, strict: bool, ignore_unexpected: elif issubclass(clazz, str): return clazz(value) elif isinstance(value, str): - return clazz.__getattr__(value) - + return clazz.__getitem__(value) raise TypeConfigException(f"expected str or int at {path}, got {type(value)}") if isclass(clazz) and issubclass(clazz, Path): diff --git a/poetry.lock b/poetry.lock index c6bc925..65b1d16 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.8.2 and should not be changed by hand. [[package]] name = "argcomplete" @@ -444,31 +444,34 @@ wcwidth = "*" [[package]] name = "pyhocon" -version = "0.3.59" +version = "0.3.60" description = "HOCON parser for Python" optional = false python-versions = "*" files = [ - {file = "pyhocon-0.3.59.tar.gz", hash = "sha256:bb0eee59b57ecea5c30d14efc7ee7e55c935d58f03025ccdfc49237e920aa48c"}, + {file = "pyhocon-0.3.60.tar.gz", hash = "sha256:ea18520ea126981e5320a72281f1a5fef2c27923f70cc54e1bd241c26525fd4b"}, ] [package.dependencies] -pyparsing = ">=2.0,<3.0" +pyparsing = {version = ">=2,<4", markers = "python_version >= \"3.0\""} [package.extras] duration = ["python-dateutil (>=2.8.0)"] [[package]] name = "pyparsing" -version = "2.4.7" -description = "Python parsing module" +version = "3.1.2" +description = "pyparsing module - Classes and methods to define and execute parsing grammars" optional = false -python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" +python-versions = ">=3.6.8" files = [ - {file = "pyparsing-2.4.7-py2.py3-none-any.whl", hash = "sha256:ef9d7589ef3c200abe66653d3f1ab1033c3c419ae9b9bdb1240a85b024efc88b"}, - {file = "pyparsing-2.4.7.tar.gz", hash = "sha256:c203ec8783bf771a155b207279b9bccb8dea02d8f0c9e5f8ead507bc3246ecc1"}, + {file = "pyparsing-3.1.2-py3-none-any.whl", hash = "sha256:f9db75911801ed778fe61bb643079ff86601aca99fcae6345aa67292038fb742"}, + {file = "pyparsing-3.1.2.tar.gz", hash = "sha256:a1bac0ce561155ecc3ed78ca94d3c9378656ad4c94c1270de543f621420f94ad"}, ] +[package.extras] +diagrams = ["jinja2", "railroad-diagrams"] + [[package]] name = "pytest" version = "8.0.2" @@ -748,4 +751,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.8" -content-hash = "f0e13e0f4d09af935fe8b51ea245aef53ab3262f7b4646152eb43b5c4fb4ca97" +content-hash = "2f6a4a17ca794f19157975c30b14b73d52c0accccb39e857a8998f0c9f2ba832" diff --git a/pyproject.toml b/pyproject.toml index b288a1d..ccb8f74 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -33,11 +33,11 @@ dataconf = 'dataconf.cli:run' [tool.poetry.dependencies] python = "^3.8" -pyhocon = "0.3.59" python-dateutil = "^2.8.2" PyYAML = "^6.0.1" -pyparsing = "2.4.7" isodate = "^0.6.1" +pyhocon = "^0.3.60" +pyparsing = "^3.1.2" [tool.poetry.group.dev.dependencies] pytest = ">=7.4.2,<9.0.0" diff --git a/tests/test_multi.py b/tests/test_multi.py index cb56d3d..4bcc23a 100644 --- a/tests/test_multi.py +++ b/tests/test_multi.py @@ -36,7 +36,7 @@ class N: class A: a: N - assert multi.string("a { b = 1\nc = 2 }").string("a { c = 3\nd = 4 }").on( + assert multi.string("a { b = 1\nc = 2 }").string("a { c = 3 \nd = 4 }").on( A ) == A(a=N(b=1, c=3, d=4))