From 1df744aaebda68487065738d2cfbbfb397181755 Mon Sep 17 00:00:00 2001 From: Caleb Marchent Date: Fri, 14 Dec 2018 12:15:47 +0000 Subject: [PATCH 1/3] Don't use pipenv for Travis builds Using language "python" in Travis starts up within a virtualenv; current version of pipenv does not like to be run within an existing virtualenv; we do require the pipenv library, to get dependencies, as we require nose for the unit tests; so these are installed manually for the travis job. Fixes #17 --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index ab7bf14..5e95076 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,9 +3,8 @@ python: - "3.6" install: - - pip3 install pipenv - - pipenv install -d --system --three - + - pip3 install pipenv nose + - python3 setup.py install script: - nosetests @@ -14,4 +13,5 @@ notifications: email: recipients: - asoli@fb.com + - cmarchent@fb.com on_failure: change # default: always From 0840a04affc4fd36913b2a4f0bc9e080188a2f6b Mon Sep 17 00:00:00 2001 From: Caleb Marchent Date: Fri, 14 Dec 2018 13:53:04 +0000 Subject: [PATCH 2/3] Support Python3.7 To start with, add 3.7 to python versions dist must be at least xenial for python3.7 --- .travis.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5e95076..3108fae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ language: python + +dist: xenial + python: - - "3.6" + - "3.6" + - "3.7" install: - pip3 install pipenv nose From 0a7f21c825983ee620d0726a9fe391b1e53f67d2 Mon Sep 17 00:00:00 2001 From: Caleb Marchent Date: Fri, 14 Dec 2018 15:59:50 +0000 Subject: [PATCH 3/3] Have a go at integrating Upstream Python3.7 support https://github.com/ilevkivskyi/typing_inspect/pull/18 Fixes #2 --- .idea/vcs.xml | 6 ++++++ nubia/internal/helpers.py | 13 +++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .idea/vcs.xml 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/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: