Skip to content

Commit

Permalink
Merge pull request #10 from quantopian/fw-remove-warnings
Browse files Browse the repository at this point in the history
General maintenance
  • Loading branch information
quantophred committed Dec 11, 2018
2 parents 44ea74f + 109e3a2 commit e8cadbf
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 20 deletions.
11 changes: 11 additions & 0 deletions .travis.yml
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion straitlets/builtin_models.py
Expand Up @@ -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. "
Expand Down
3 changes: 3 additions & 0 deletions 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

Expand All @@ -25,6 +27,7 @@ def ensure_unicode(s, encoding='utf-8'):


__all__ = [
'argspec',
'ensure_bytes',
'ensure_unicode',
'long',
Expand Down
20 changes: 8 additions & 12 deletions straitlets/ext/tests/test_click.py
Expand Up @@ -59,28 +59,24 @@ 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 <.+?>
int:
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 <.+?>
$""",
""",
),
)

Expand Down Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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):
Expand All @@ -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)
6 changes: 3 additions & 3 deletions straitlets/tests/test_examples.py
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion straitlets/tests/test_serializable.py
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions straitlets/to_primitive.py
Expand Up @@ -13,6 +13,7 @@ def to_primitive(obj):
)
)


_base_handler = to_primitive.dispatch(object)


Expand Down
5 changes: 3 additions & 2 deletions straitlets/traits.py
Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand All @@ -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 = {
Expand Down
5 changes: 4 additions & 1 deletion tox.ini
@@ -1,5 +1,5 @@
[tox]
envlist=py{27,34,35}
envlist=py{27,34,35,36,37}
skip_missing_interpreters=True

[testenv]
Expand All @@ -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

0 comments on commit e8cadbf

Please sign in to comment.