It appears that starting with sphinx 1.7.1, the code uses the typing module that was introduced in python 3.5. This presumably means the code will no longer work with python 3.4, which is still documented as being the oldest supported version. Furthermore the use of the TYPE_CHECKING attribute means that versions prior to python 3.5.3 will not work (which is how I noticed this).
For instance, see here
It seems like you should either avoid the typing module entirely, conditionalize the imports somehow or update your documented dependencies to state that you require 3.5.3.
OMG.... I thought the TYPE_CHECKING is supported since 3.5. I'll check it ASAP.
Thank you for letting me know!
The doc for TYPE_CHECKING does not state that it was not in the original version of the typing module, so there would be no way to know if you didn't explicitly check older versions.
In any case, there is still the issue that the typing module itself was not present in 3.4. Is sphinx dropping 3.4 support?
Sphinx depends on typing backports package when <= 3.4. So py34 is still supported.
https://pypi.python.org/pypi/typing
typing.TYPE_CHECKING is introduced at this commit https://github.com/python/cpython/commit/91185fe0284a04162e0b3425b53be49bdbfad67d#diff-015978a768b517a38abbc0ecdea87f5aR72 (on 9 Jun 2016),
and the Python version at this point was 3.5.1.
3.5.1 final was released on December 6, 2015 according PEP 478, so Sphinx should use typing backports package when <= 3.5.0. (Maybe that case are rare.)
For what its worth, I observed this problem on a system that says it has python 1.5.1, and I definitely did not install a prerelease. Furthermore, if you look at the online docs for the typing module the TYPE_CHECKING variable does not show up until 1.5.3. You should check actual deployments before making any conclusions about what versions work.
I just created conda environment for python 1.5.1 on Mac OSX and sure enough there is no TYPE_CHECKING. It does appear in the 1.5.2.
So you should use the backports package when <= 3.5.1
Sorry for my wrong comment. I had misunderstanding that 3.5.1 final was released on December 6, 2016.
typing.TYPE_CHECKING was released at Python 3.5.2, so your opinion is absolutely true.
The typing PyPI page has the following disclaimer:
NOTE: in Python 3.5 and later, the typing module lives in the stdlib, and installing this package has NO EFFECT. To get a newer version of the typing module in Python 3.5 or later, you have to upgrade to a newer Python (bugfix) version. For example, typing in Python 3.6.0 is missing the definition of ‘Type’ – upgrading to 3.6.2 will fix this.
So with Python 3.5.1, even with the typing package installed, TYPE_CHECKING is not available. I have verified this locally. With this, it seems the latest Sphinx release simply isn't compatible with Python 3.5.0 & 3.5.1.
Fixed by #4735.
Thank you for reporting!
Most helpful comment
For what its worth, I observed this problem on a system that says it has python 1.5.1, and I definitely did not install a prerelease. Furthermore, if you look at the online docs for the typing module the
TYPE_CHECKINGvariable does not show up until 1.5.3. You should check actual deployments before making any conclusions about what versions work.I just created conda environment for python 1.5.1 on Mac OSX and sure enough there is no
TYPE_CHECKING. It does appear in the 1.5.2.So you should use the backports package when <= 3.5.1