From f784eca73aeed572f022c2dd2690f75d9aa48b93 Mon Sep 17 00:00:00 2001 From: Kyle Walker Date: Wed, 13 Mar 2019 16:12:37 -0700 Subject: [PATCH 1/3] Limit PyYaml & Flake8 Fixes --- .python-version | 9 +++++---- Makefile | 15 +++------------ setup.py | 4 ++-- tests/test_yamldict.py | 6 +++--- tox.ini | 2 +- 5 files changed, 14 insertions(+), 22 deletions(-) diff --git a/.python-version b/.python-version index 9f9adc3..fec5397 100644 --- a/.python-version +++ b/.python-version @@ -1,4 +1,5 @@ -3.6.3 -3.4.3 -3.5.4 -2.7.14 +ys-dev +3.7.2 +3.6.6 +3.5.6 +2.7.9 diff --git a/Makefile b/Makefile index ceb0e5e..2182526 100644 --- a/Makefile +++ b/Makefile @@ -11,20 +11,11 @@ clean: @find . -name '*.pyc' -delete @find . -name '__pycache__' -delete -pyenv_envs: - pip install -U detox tox tox-pyenv - CFLAGS="-I$(shell brew --prefix openssl)/include" LDFLAGS="-L$(shell brew --prefix openssl)/lib" pyenv install 2.7.14 - CFLAGS="-I$(shell brew --prefix openssl)/include" LDFLAGS="-L$(shell brew --prefix openssl)/lib" pyenv install 3.4.3 - CFLAGS="-I$(shell brew --prefix openssl)/include" LDFLAGS="-L$(shell brew --prefix openssl)/lib" pyenv install 3.5.4 - CFLAGS="-I$(shell brew --prefix openssl)/include" LDFLAGS="-L$(shell brew --prefix openssl)/lib" pyenv install 3.6.3 - pyenv local 2.7.14 3.4.3 3.5.4 3.6.3 - pip install -U detox tox tox-pyenv pip setuptools - test3: - -tox -e py36 $(test_extra_params) + -tox -e py37 $(test_extra_params) test: - detox + tox -p auto build: - PYENV_VERSION=yset-36 python setup.py build + PYENV_VERSION=ys-dev python setup.py build diff --git a/setup.py b/setup.py index db4c254..e641364 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ requirements = { "package": [ - "PyYAML", + "PyYAML>=2,<4", ], "test": [ "nose", @@ -25,7 +25,7 @@ setup( name='yamlsettings', - version='1.0.2', + version='1.0.3', description='Yaml Settings Configuration Module', long_description=readme, author='Kyle James Walker', diff --git a/tests/test_yamldict.py b/tests/test_yamldict.py index 081dfec..66b44c0 100644 --- a/tests/test_yamldict.py +++ b/tests/test_yamldict.py @@ -121,13 +121,13 @@ def test_load_all(self): for test_input in ['fancy.yml', ['fancy.yml']]: section_count = 0 for c_yml in load_all(test_input): - if section_count is 0: + if section_count == 0: self.assertEqual(c_yml.test.id1.name, 'hi') self.assertEqual(c_yml.test.test[2].sub_test.a, 10) self.assertEqual(c_yml.test.test[2].sub_test.b.name, 'hi') - elif section_count is 1: + elif section_count == 1: self.assertEqual(c_yml.test_2.test2.message, 'same here') - elif section_count is 2: + elif section_count == 2: self.assertEqual(c_yml.test_3.test.name, 'Hello') section_count += 1 self.assertEqual(section_count, 3) diff --git a/tox.ini b/tox.ini index 182fdc7..2ba8511 100644 --- a/tox.ini +++ b/tox.ini @@ -3,7 +3,7 @@ max-line-length = 80 max-complexity = 20 [tox] -envlist = py27, py34, py35, py36 +envlist = py27, py35, py36, py37 [testenv] deps = From 19b6b680df82922ef4326a09c0501bbc467de2d6 Mon Sep 17 00:00:00 2001 From: Kyle Walker Date: Wed, 13 Mar 2019 16:15:52 -0700 Subject: [PATCH 2/3] Flake8 Fixes --- yamlsettings/yamldict.py | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/yamlsettings/yamldict.py b/yamlsettings/yamldict.py index 1809641..f2ff987 100644 --- a/yamlsettings/yamldict.py +++ b/yamlsettings/yamldict.py @@ -72,27 +72,27 @@ def update(self, yaml_dict): ''' Update the content (i.e. keys and values) with yaml_dict. ''' def _update_node(base_node, update_node): - if isinstance(update_node, YAMLDict) or \ - isinstance(update_node, dict): - if not (isinstance(base_node, YAMLDict)): - # NOTE: A regular dictionary is replaced by a new - # YAMLDict object. - new_node = YAMLDict() - else: - new_node = base_node - for k, v in update_node.items(): - new_node[k] = _update_node(new_node.get(k), v) - elif isinstance(update_node, list) or \ - isinstance(update_node, tuple): - # NOTE: A list/tuple is replaced by a new list/tuple. - new_node = [] - for v in update_node: - new_node.append(_update_node(None, v)) - if isinstance(update_node, tuple): - new_node = tuple(new_node) + if isinstance(update_node, YAMLDict) or \ + isinstance(update_node, dict): + if not (isinstance(base_node, YAMLDict)): + # NOTE: A regular dictionary is replaced by a new + # YAMLDict object. + new_node = YAMLDict() else: - new_node = update_node - return new_node + new_node = base_node + for k, v in update_node.items(): + new_node[k] = _update_node(new_node.get(k), v) + elif isinstance(update_node, list) or \ + isinstance(update_node, tuple): + # NOTE: A list/tuple is replaced by a new list/tuple. + new_node = [] + for v in update_node: + new_node.append(_update_node(None, v)) + if isinstance(update_node, tuple): + new_node = tuple(new_node) + else: + new_node = update_node + return new_node # Convert non-YAMLDict objects to a YAMLDict if not (isinstance(yaml_dict, YAMLDict) or isinstance(yaml_dict, dict)): From eb1b7d4f74a2162f05b8d483c4f1e278cc9113f2 Mon Sep 17 00:00:00 2001 From: Kyle Walker Date: Wed, 13 Mar 2019 16:20:59 -0700 Subject: [PATCH 3/3] PyYAML v3 or older --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index e641364..cf1de1c 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ requirements = { "package": [ - "PyYAML>=2,<4", + "PyYAML<4", ], "test": [ "nose",