Skip to content

Commit

Permalink
Force use of backports.typing in python < 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Didion, John (NIH/NHGRI) [F] committed May 22, 2017
1 parent f4e6ef2 commit 89c6670
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@ install:
test:
$(TEST)

clean:
rm -Rf __pycache__
rm -Rf **/__pycache__/*
rm -Rf dist
rm -Rf build
rm -Rf *.egg-info

release:
# make sure required variables set via commandline
ifndef version
$(error version is not set)
endif
ifndef token
$(error token is not set)
endif
$(clean)
# tag
git tag $(version)
# build
Expand Down
12 changes: 8 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
if sys.version_info < (3, 3):
sys.stdout.write("At least Python 3.3 is required.\n")
sys.exit(1)
elif sys.version_info < (3, 5):
# typing was added in 3.5, but a backport is available for 3.3+
requirements.append('typing')
elif sys.version_info < (3, 6):
# typing was added in 3.5, and we rely on critical features that were
# introduced in 3.5.2+, so for versions older than 3.6 we rely on
# a backport
requirements.append('backports.typing')

import versioneer

Expand All @@ -30,9 +32,11 @@
'Topic :: Software Development :: Libraries :: Python Modules',
'License :: MIT',
'License :: Public Domain',
'Programming Language :: Python :: 3 :: Only',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6'
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.6',
],
)
15 changes: 11 additions & 4 deletions xphyle/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,17 @@
import stat
import sys
from types import ModuleType
from typing import *
# ISSUE: Not sure why I have to import IO separately
from typing import IO
from typing.re import *
# HACK: critical features were introduced in python 3.5.2, so we force use
# of backports.typing even in 3.5
if sys.version_info < (3, 6):
from backports.typing import *
from backports.typing import IO
from backports.typing.re import *
else:
from typing import *
# ISSUE: Not sure why I have to import IO separately
from typing import IO
from typing.re import *

# ISSUE: there are several mypy errors due to incomplete enum support.
# enums should be fully suported in the next version of mypy (>0.501).
Expand Down

0 comments on commit 89c6670

Please sign in to comment.