Skip to content

Commit 29c1772

Browse files
committed
drop python 2.7, upgrade pyyaml and use safe_ functions to fix #21
1 parent 58ec7b9 commit 29c1772

File tree

9 files changed

+29
-43
lines changed

9 files changed

+29
-43
lines changed

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ language: python
22
sudo: required
33
dist: xenial
44
python:
5-
- "2.7"
6-
- "3.4"
75
- "3.5"
86
- "3.6"
97
- "3.7"

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2018 Alexandre Ferland
3+
Copyright (c) 2019 Alexandre Ferland
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

dev_requirements.txt

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-r requirements.txt
22

3-
Flask==1.0.2
4-
kazoo==2.6.0
5-
pytest==4.0.0
6-
python-consul==1.1.0
7-
python-etcd==0.4.5
3+
Flask>=1.0.2
4+
kazoo>=2.6.0
5+
pytest>=4.0.0
6+
python-consul>=1.1.0
7+
python-etcd>=0.4.5

requirements.txt

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
distconfig==0.1.0
2-
future==0.17.1
3-
pathlib==1.0.1
4-
pytoml==0.1.20
5-
PyYAML==3.13
6-
watchdog==0.9.0
1+
distconfig>=0.1.0
2+
pathlib>=1.0.1
3+
pytoml>=0.1.20
4+
PyYAML>=5.1
5+
watchdog>=0.9.0

setup.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
setup(
44
name='vyper-config',
5-
version='0.3.3',
5+
version='0.4.0',
66
description='Python configuration with more fangs',
77
url='http://github.com/admiralobvious/vyper',
88
author='Alexandre Ferland',
@@ -12,21 +12,18 @@
1212
zip_safe=False,
1313
install_requires=[
1414
'distconfig>=0.1.0',
15-
'future>=0.17.1',
1615
'pathlib>=1.0.1',
1716
'pytoml>=0.1.20',
18-
'PyYAML>=3.13',
17+
'PyYAML>=5.1',
1918
'watchdog>=0.9.0'
2019
],
21-
setup_requires=["pytest-runner>=4.2"],
22-
tests_require=["pytest>=3.10.1"],
20+
setup_requires=["pytest-runner>=5.1"],
21+
tests_require=["pytest>=5.0.1"],
2322
platforms='any',
2423
classifiers=[
2524
'Intended Audience :: Developers',
2625
'License :: OSI Approved :: MIT License',
2726
'Operating System :: OS Independent',
28-
'Programming Language :: Python :: 2.7',
29-
'Programming Language :: Python :: 3.4',
3027
'Programming Language :: Python :: 3.5',
3128
'Programming Language :: Python :: 3.6',
3229
'Programming Language :: Python :: 3.7',

tests/test_vyper.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def setUp(self):
102102

103103
def _init_configs(self):
104104
self.v.set_config_type("yaml")
105-
r = yaml.dump(text(yaml_example))
105+
r = yaml.safe_dump(text(yaml_example))
106106
self.v._unmarshall_reader(r, self.v._config)
107107

108108
self.v.set_config_type("json")
@@ -115,7 +115,7 @@ def _init_configs(self):
115115

116116
def _init_yaml(self):
117117
self.v.set_config_type("yaml")
118-
r = yaml.dump(yaml_example)
118+
r = yaml.safe_dump(yaml_example)
119119
self.v._unmarshall_reader(r, self.v._config)
120120

121121
def _init_json(self, fixture=None):
@@ -166,7 +166,7 @@ def test_default(self):
166166

167167
def test_unmarshalling(self):
168168
self.v.set_config_type("yaml")
169-
r = yaml.dump(yaml_example)
169+
r = yaml.safe_dump(yaml_example)
170170
self.v._unmarshall_reader(r, self.v._config)
171171
self.assertTrue(self.v.in_config("name"))
172172
self.assertFalse(self.v.in_config("state"))
@@ -175,7 +175,7 @@ def test_unmarshalling(self):
175175

176176
def test_yaml_duplication_nested(self):
177177
self.v.set_config_type("yaml")
178-
r = yaml.dump(yaml_duplicate_in_nested)
178+
r = yaml.safe_dump(yaml_duplicate_in_nested)
179179
self.v._unmarshall_reader(r, self.v._config)
180180
self.assertEqual("yeap", self.v.get("sweet.home.alabama"))
181181
self.assertEqual("noway", self.v.get("sweet.job.alabama"))
@@ -238,7 +238,7 @@ def test_args_with_bad_value(self):
238238
def test_args_override(self):
239239
# Yaml config
240240
self.v.set_config_type("yaml")
241-
r = yaml.dump("yaml_param: from_yaml")
241+
r = yaml.safe_dump("yaml_param: from_yaml")
242242
self.v._unmarshall_reader(r, self.v._config)
243243

244244
# Overrides
@@ -403,7 +403,7 @@ def test_unmarshall(self):
403403

404404
def test_is_set(self):
405405
self.v.set_config_type("yaml")
406-
self.v.read_config(yaml.dump(text(yaml_example)))
406+
self.v.read_config(yaml.safe_dump(text(yaml_example)))
407407
self.assertTrue(self.v.is_set("clothing.jacket"))
408408
self.assertFalse(self.v.is_set("clothing.jackets"))
409409
self.assertFalse(self.v.is_set("helloworld"))
@@ -483,7 +483,7 @@ def test_complex_bound_case_sensitivity(self):
483483

484484
def test_sub(self):
485485
self.v.set_config_type("yaml")
486-
self.v.read_config(yaml.dump(text(yaml_example)))
486+
self.v.read_config(yaml.safe_dump(text(yaml_example)))
487487

488488
subv = self.v.sub("clothing")
489489
self.assertEqual(self.v.get("clothing.pants.size"),
@@ -530,10 +530,10 @@ def test_merge_config(self):
530530
y = "b: xyz"
531531
self.v.set_config_type("yaml")
532532

533-
self.v.read_config(yaml.dump(text(x)))
533+
self.v.read_config(yaml.safe_dump(text(x)))
534534
self.assertEqual(self.v.get("a"), "abc")
535535

536-
self.v.merge_config(yaml.dump(text(y)))
536+
self.v.merge_config(yaml.safe_dump(text(y)))
537537
self.assertEqual(self.v.get("a"), "abc")
538538
self.assertEqual(self.v.get("b"), "xyz")
539539

@@ -542,8 +542,8 @@ def test_merge_overwrite_key(self):
542542
y = "a: xyz"
543543
self.v.set_config_type("yaml")
544544

545-
self.v.read_config(yaml.dump(text(x)))
545+
self.v.read_config(yaml.safe_dump(text(x)))
546546
self.assertEqual(self.v.get("a"), "abc")
547547

548-
self.v.merge_config(yaml.dump(text(y)))
548+
self.v.merge_config(yaml.safe_dump(text(y)))
549549
self.assertEqual(self.v.get("a"), "xyz")

vyper/remote.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import
2-
31
from distconfig import Proxy
42
import pytoml as toml
53
import yaml
@@ -50,7 +48,7 @@ def _get_parser(self):
5048
if self.config_type == "json":
5149
return json.loads
5250
elif self.config_type in ["yaml", "yml"]:
53-
return yaml.load
51+
return yaml.safe_load
5452
elif self.config_type == "toml":
5553
return toml.loads
5654

@@ -72,4 +70,3 @@ def add_listener(self, cb=None):
7270

7371
def _update_kvstore(self, e):
7472
self.v._kvstore = e
75-

vyper/util.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ def unmarshall_config_reader(file_, d, config_type):
5151

5252
if config_type in ["yaml", "yml"]:
5353
try:
54-
f = yaml.load(file_)
54+
f = yaml.safe_load(file_)
5555
try:
56-
d.update(yaml.load(f))
56+
d.update(yaml.safe_load(f))
5757
except AttributeError: # to read files
5858
d.update(f)
5959
except Exception as e:

vyper/vyper.py

-5
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import os
44
import pprint
55

6-
from builtins import str as text
7-
86
from . import constants, errors, remote, util, watch
97

108
log = logging.getLogger("vyper")
@@ -215,9 +213,6 @@ def get_int(self, key):
215213
def get_float(self, key):
216214
return float(self.get(key))
217215

218-
def get_unicode(self, key):
219-
return text(self.get(key))
220-
221216
def get_bytes(self, key):
222217
return b"{0}".format(self.get(key))
223218

0 commit comments

Comments
 (0)