diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index ab7bf14..3108fae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,14 @@ language: python + +dist: xenial + python: - - "3.6" + - "3.6" + - "3.7" install: - - pip3 install pipenv - - pipenv install -d --system --three - + - pip3 install pipenv nose + - python3 setup.py install script: - nosetests @@ -14,4 +17,5 @@ notifications: email: recipients: - asoli@fb.com + - cmarchent@fb.com on_failure: change # default: always diff --git a/nubia/internal/helpers.py b/nubia/internal/helpers.py index 66e5290..f365608 100644 --- a/nubia/internal/helpers.py +++ b/nubia/internal/helpers.py @@ -12,9 +12,11 @@ import signal import string import subprocess +import sys from collections import namedtuple -from typing import _Union, Any, Iterable # noqa T484 +from typing import Any, Union, Iterable # noqa T484 + def add_command_arguments(parser, options): @@ -168,6 +170,7 @@ def issubclass_(obj, class_): def is_union(t: Any) -> bool: """Check whether type is a Union. + @param t: type to check @type: Any @returns: `True` if type is a Union, `False` otherwise @@ -177,7 +180,13 @@ def is_union(t: Any) -> bool: https://github.com/ilevkivskyi/typing_inspect for the rationale behind the implementation. """ - return type(t) is _Union + if sys.version_info[:3] >= (3, 7, 0): # PEP 560 + from typing import _GenericAlias + return (t is Union or + isinstance(t, _GenericAlias) and t.__origin__ is Union) + else: + from typing import _Union + return type(t) is _Union def is_optional(t: Any) -> bool: