Skip to content

Commit 16fe5da

Browse files
ilevkivskyipre-commit-ci[bot]
authored andcommitted
Fix readthedocs build (#15437)
I initially included an error (removed allowlisted error code that is not covered), to verify it will be caught. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 9b327d1 commit 16fe5da

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Diff for: .github/workflows/docs.yml

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ jobs:
2020
env:
2121
TOXENV: docs
2222
TOX_SKIP_MISSING_INTERPRETERS: False
23+
VERIFY_MYPY_ERROR_CODES: 1
2324
steps:
2425
- uses: actions/checkout@v3
2526
- uses: actions/setup-python@v4

Diff for: docs/source/html_builder.py

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import json
4+
import os
45
import textwrap
56
from pathlib import Path
67
from typing import Any
@@ -9,8 +10,6 @@
910
from sphinx.application import Sphinx
1011
from sphinx.builders.html import StandaloneHTMLBuilder
1112

12-
from mypy.errorcodes import error_codes
13-
1413

1514
class MypyHTMLBuilder(StandaloneHTMLBuilder):
1615
def __init__(self, app: Sphinx) -> None:
@@ -21,7 +20,9 @@ def write_doc(self, docname: str, doctree: document) -> None:
2120
super().write_doc(docname, doctree)
2221
self._ref_to_doc.update({_id: docname for _id in doctree.ids})
2322

24-
def _write_ref_redirector(self) -> None:
23+
def _verify_error_codes(self) -> None:
24+
from mypy.errorcodes import error_codes
25+
2526
known_missing = {
2627
# TODO: fix these before next release
2728
"annotation-unchecked",
@@ -39,6 +40,10 @@ def _write_ref_redirector(self) -> None:
3940
raise ValueError(
4041
f"Some error codes are not documented: {', '.join(sorted(missing_error_codes))}"
4142
)
43+
44+
def _write_ref_redirector(self) -> None:
45+
if os.getenv("VERIFY_MYPY_ERROR_CODES"):
46+
self._verify_error_codes()
4247
p = Path(self.outdir) / "_refs.html"
4348
data = f"""
4449
<html>

Diff for: tox.ini

+2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ commands =
3333

3434
[testenv:docs]
3535
description = invoke sphinx-build to build the HTML docs
36+
passenv =
37+
VERIFY_MYPY_ERROR_CODES
3638
deps = -rdocs/requirements-docs.txt
3739
commands =
3840
sphinx-build -d "{toxworkdir}/docs_doctree" docs/source "{toxworkdir}/docs_out" --color -W -bhtml {posargs}

0 commit comments

Comments
 (0)