diff --git a/.travis.yml b/.travis.yml index 711e44c..dd8fcfe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,15 @@ python: - "2.7" - "3.4" - "3.5" + - "3.6" + +# Python 3.7 requires OpenSSL 1.0.2+, which is only available on Travis +# via xenial and sudo. Require them for only the build that needs them. +matrix: + include: + - python: "3.7" + dist: xenial + sudo: true before_script: - pip install tox @@ -12,3 +21,5 @@ script: - if [[ $TRAVIS_PYTHON_VERSION = '2.7' ]]; then tox -e py27; fi - if [[ $TRAVIS_PYTHON_VERSION = '3.4' ]]; then tox -e py34; fi - if [[ $TRAVIS_PYTHON_VERSION = '3.5' ]]; then tox -e py35; fi + - if [[ $TRAVIS_PYTHON_VERSION = '3.6' ]]; then tox -e py36; fi + - if [[ $TRAVIS_PYTHON_VERSION = '3.7' ]]; then tox -e py37; fi diff --git a/straitlets/builtin_models.py b/straitlets/builtin_models.py index c871ba4..7592169 100644 --- a/straitlets/builtin_models.py +++ b/straitlets/builtin_models.py @@ -127,7 +127,7 @@ def _password_requires_user(self, proposal): return new hosts = List( - trait=Unicode, + trait=Unicode(), minlen=1, help=( "List of hosts in the replicaset. " diff --git a/straitlets/compat.py b/straitlets/compat.py index 0108f30..d9a510c 100644 --- a/straitlets/compat.py +++ b/straitlets/compat.py @@ -1,9 +1,11 @@ from six import PY3 if PY3: # pragma: no cover + from inspect import getfullargspec as argspec # noqa long = int unicode = str else: # pragma: no cover + from inspect import getargspec as argspec # noqa long = long unicode = unicode @@ -25,6 +27,7 @@ def ensure_unicode(s, encoding='utf-8'): __all__ = [ + 'argspec', 'ensure_bytes', 'ensure_unicode', 'long', diff --git a/straitlets/ext/tests/test_click.py b/straitlets/ext/tests/test_click.py index 0f1e603..74032cd 100644 --- a/straitlets/ext/tests/test_click.py +++ b/straitlets/ext/tests/test_click.py @@ -59,9 +59,7 @@ def missing_attr_instance(): multi_error_output = re.compile( dedent( """\ - ^Usage: main \[OPTIONS\] - - Error: Invalid value for "--config": Failed to validate the schema: + Failed to validate the schema: bool: No default value found for bool trait of <.+?> @@ -69,18 +67,16 @@ def missing_attr_instance(): No default value found for int trait of <.+?> unicode: No default value found for unicode trait of <.+?> - $""", + """, ), ) single_error_output = re.compile( dedent( """\ - ^Usage: main \[OPTIONS\] - - Error: Invalid value for "--config": Failed to validate the schema: + Failed to validate the schema: No default value found for int trait of <.+?> - $""", + """, ), ) @@ -128,7 +124,7 @@ def main(config): # pragma: no cover catch_exceptions=False, ) assert result.exit_code - assert multi_error_output.match(result.output) + assert multi_error_output.search(result.output) def test_json_single_error(runner, missing_attr_instance): @@ -148,7 +144,7 @@ def main(config): # pragma: no cover catch_exceptions=False, ) assert result.exit_code - assert single_error_output.match(result.output) + assert single_error_output.search(result.output) def test_yaml_file(runner, expected_instance): @@ -194,7 +190,7 @@ def main(config): # pragma: no cover catch_exceptions=False, ) assert result.exit_code - assert multi_error_output.match(result.output) + assert multi_error_output.search(result.output) def test_yaml_single_error(runner, missing_attr_instance): @@ -214,4 +210,4 @@ def main(config): # pragma: no cover catch_exceptions=False, ) assert result.exit_code - assert single_error_output.match(result.output) + assert single_error_output.search(result.output) diff --git a/straitlets/tests/test_examples.py b/straitlets/tests/test_examples.py index eb42432..90acc81 100644 --- a/straitlets/tests/test_examples.py +++ b/straitlets/tests/test_examples.py @@ -152,14 +152,14 @@ def test_nested_example(): class C(Serializable): point = Instance(Point) - unicode_ = Unicode(example='foo') + unicode_ = Unicode().tag(example='foo') class B(Serializable): - value = Integer(example=ord('b')) + value = Integer().tag(example=ord('b')) next_ = Instance(C) class A(Serializable): - value = Integer(example=ord('a')) + value = Integer().tag(example=ord('a')) next_ = Instance(B) expected = A( diff --git a/straitlets/tests/test_serializable.py b/straitlets/tests/test_serializable.py index 6132447..bb70a6a 100644 --- a/straitlets/tests/test_serializable.py +++ b/straitlets/tests/test_serializable.py @@ -109,7 +109,7 @@ class DynamicDefaults(Serializable): def _d_default(self): return self.DEFAULT_D - l = List() + l = List() # noqa DEFAULT_L = [1, 2, not_ascii, 3] def _l_default(self): diff --git a/straitlets/to_primitive.py b/straitlets/to_primitive.py index f93f757..0de461b 100644 --- a/straitlets/to_primitive.py +++ b/straitlets/to_primitive.py @@ -13,6 +13,7 @@ def to_primitive(obj): ) ) + _base_handler = to_primitive.dispatch(object) diff --git a/straitlets/traits.py b/straitlets/traits.py index ce743ad..e831131 100644 --- a/straitlets/traits.py +++ b/straitlets/traits.py @@ -8,10 +8,10 @@ - More strict handling of default values than traitlets' built-in behavior. """ from contextlib import contextmanager -import inspect import traitlets as tr +from . import compat from .to_primitive import to_primitive, can_convert_to_primitive @@ -97,7 +97,7 @@ def _get_default_value_sentinel(t): # signature. if t is tr.Tuple: return tr.Undefined - argspec = inspect.getargspec(t.__init__) + argspec = compat.argspec(t.__init__) for name, value in zip(reversed(argspec.args), reversed(argspec.defaults)): if name == 'default_value': return value @@ -106,6 +106,7 @@ def _get_default_value_sentinel(t): "Can't find default value sentinel for type %s" % t ) + _NOTPASSED = object() _TRAITLETS_CONTAINER_TYPES = frozenset([tr.List, tr.Set, tr.Dict, tr.Tuple]) _DEFAULT_VALUE_SENTINELS = { diff --git a/tox.ini b/tox.ini index 83d2983..539ce56 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist=py{27,34,35} +envlist=py{27,34,35,36,37} skip_missing_interpreters=True [testenv] @@ -10,3 +10,6 @@ commands= [pytest] addopts = --pep8 --cov straitlets --cov-report term-missing --cov-report html testpaths = straitlets +filterwarnings = + # PyYAML==3.13 + ignore:Using or importing the ABCs:DeprecationWarning:yaml.constructor:126