RE: type hinting backward compatibility with python 3.0 to 3.4

2017-05-19 Thread Edward Ned Harvey (python)
This pattern seems to work: import sys if sys.version_info[0] < 3: raise RuntimeError("Must use at least python version 3") # The 'typing' module, useful for type hints, was introduced in python 3.5 if sys.version_info[1] >= 5: from typing import Optional optional_float = Optional[fl

type hinting backward compatibility with python 3.0 to 3.4

2017-05-19 Thread Edward Ned Harvey (python)
I think it's great that for built-in types such as int and str, backward compatibility of type hinting annotations is baked into python 3.0 to 3.4. In fact, I *thought* python 3.0 to 3.4 would *ignore* annotations, but it doesn't... I'm struggling to create something backward compatible that re