The doc build failure here is due to python/mypy#2394 by Guido... See python/mypy#2593. py27-sphinx compatibility can be quite easily restored; I'm waiting for an official response.
Meanwhile, my unofficial patch can be found in #8073. There's also an unrelated theme fix that not only applies to 0.4.6.
@ilovezfs Feel free to close #8073 and apply the changes here. But I figured you have enough open PRs to worry about.
mypy 0.4.6
==========
- [x] Have you followed the [guidelines for contributing](https://github.com/Homebrew/homebrew-core/blob/master/CONTRIBUTING.md)?
- [x] Have you checked that there aren't other open [pull requests](https://github.com/Homebrew/homebrew-core/pulls) for the same formula update/change?
- [x] Have you built your formula locally with `brew install --build-from-source <formula>`, where `<formula>` is the name of the formula you're submitting?
- [x] Does your build pass `brew audit --strict <formula>` (after doing `brew install <formula>`)?
-----
Duplicate of #7143, which is seemingly abandoned.
- Add `mypy/version_static.py` during doc build to work around https://github.com/python/mypy/issues/2593. Pending official patch or rejection of py27-sphinx compatibility.
- Fix Sphinx theme. Sphinx does NOT recognize `PYTHONPATH`, so installing `sphinx_rtd_theme` to `libexec/vendor` then pointing `PYTHONPATH` there is useless. Instead, we install `sphinx_rtd_theme` to `buildpath/docs`, then directly modify `sys.path` in Sphinx's `conf.py`.
Note that this has to be patched downstream because it's simply a limitation in our sphinx-doc.
Comparison: before (wrong theme):

after (correct theme):

Regression: Docs no longer build with py27-sphinx since #2394
=============================================================
Docs used to build just fine with Sphinx under Python 2.7. #2394 introduced an import `mypy.git` to `mypy.version` (which is imported by Sphinx's `conf.py`), and since `mypy.git` contains function annotations not supported by Python 2.7, trying to build the docs with py27-sphinx now causes an error:
```
$ make html
sphinx-build -b html -d build/doctrees source build/html
Running Sphinx v1.5.1
Configuration error:
There is a syntax error in your configuration file: invalid syntax (git.py, line 10)
make: *** [html] Error 1
```
This unfortunately is causing some trouble for Homebrew (see https://github.com/Homebrew/homebrew-core/pull/7143), since our `sphinx-doc` formula is py27 only at the moment.
We'll of course try to fix this on Homebrew's side, but maybe py27-sphinx compatibility could be restored? One solution I can think of is to add something like `mypy/version_static.py` with the plain old version declaration:
```py
__version__ = '0.4.7-dev'
```
then import `mypy.version_static` in `docs/source/conf.py` instead. The downside is it needs to be bumped alongside `version.py` at the same time, and when building from a git tree, the commit hash won't be included in the docs.