Skip to content

Commit 82e6ff9

Browse files
Merge pull request #26 from UAVCAN/py3.5-compat-fix
Python compatibility clarifications
2 parents 9a0bd72 + d8b6aba commit 82e6ff9

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

.travis.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,18 @@ os:
55
- linux # Travis does not support Python on OSX or Windows. Should we migrate to a different CI service?
66

77
python:
8-
- 3.5
9-
- 3.6
10-
- 3.7-dev # TODO: Replace with plain "3.7" when supported by Travis
11-
# - 3.8-dev # TODO: Compatibility issues with MyPy, see https://travis-ci.org/UAVCAN/pydsdl/jobs/519988157
8+
- '3.5.3' # Oldest supported version
9+
- '3.5'
10+
- '3.6'
11+
- '3.7-dev' # TODO: Replace with plain "3.7" when supported by Travis
12+
# - '3.8-dev' # TODO: Compatibility issues with MyPy, see https://travis-ci.org/UAVCAN/pydsdl/jobs/519988157
1213

1314
before_script:
1415
- pip install -r requirements.txt
1516
- pip install coveralls # Intentionally removed from requirements.txt because it's only useful in the CI environment
1617

1718
script:
19+
- python --version
1820
- ./test.sh
1921
- coveralls # Publish the coverage stats online.
2022
- git clone https://github.com/UAVCAN/dsdl --branch=uavcan-v1.0 dsdl-test # TODO: Switch to master once v1.0 is merged

pydsdl/__init__.py

+25-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,33 @@
66
import os as _os
77
import sys as _sys
88

9-
if _sys.version_info[:2] < (3, 5): # pragma: no cover
10-
print('A newer version of Python is required', file=_sys.stderr)
9+
# The original intent was to support Python 3.5 and newer; however, we have discovered a bug in the static typing
10+
# library in Python 3.5.2 which makes the library quite unusable: when importing, the typing module would throw
11+
# "TypeError: This Callable type is already parameterized." from the expression module. The problem does not appear
12+
# in Python 3.5.3 or any newer versions; it is fixed in the upstream here: https://github.com/python/typing/pull/308.
13+
# This is how you can reproduce it in REPL; first, the correct behavior that can be observed in Python 3.5.3+:
14+
# >>> import typing
15+
# >>> T = typing.TypeVar('T')
16+
# >>> G = typing.Callable[[], T]
17+
# >>> G[int]
18+
# typing.Callable[[], int]
19+
# And this is what you get in Python 3.5.2-:
20+
# >>> import typing
21+
# >>> T = typing.TypeVar('T')
22+
# >>> G = typing.Callable[[], T]
23+
# >>> G[int]
24+
# Traceback (most recent call last):
25+
# File "<stdin>", line 1, in <module>
26+
# File "/usr/lib/python3.5/typing.py", line 815, in __getitem__
27+
# raise TypeError("This Callable type is already parameterized.")
28+
# TypeError: This Callable type is already parameterized.
29+
_min_supported_python_version = 3, 5, 3
30+
if _sys.version_info[:3] < _min_supported_python_version: # pragma: no cover
31+
print('This package requires a Python version', '.'.join(map(str, _min_supported_python_version)), 'or newer',
32+
file=_sys.stderr)
1133
_sys.exit(1)
1234

13-
__version__ = 0, 7, 3
35+
__version__ = 0, 8, 0
1436
__license__ = 'MIT'
1537

1638
# Our unorthodox approach to dependency management requires us to apply certain workarounds.

0 commit comments

Comments
 (0)