Skip to content

Commit 0bd84f9

Browse files
generate the strict list in the build dir, so there won't be any funky path trouble
1 parent 80dc22d commit 0bd84f9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

docs/source/command_line.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ of the above sections.
764764
:option:`mypy --help` output.
765765

766766
Note: the exact list of flags enabled by running :option:`--strict` may change
767-
over time. For the current version of mypy, the list is:
767+
over time. For the this version of mypy, the list is:
768768

769769
.. include:: strict_list.rst
770770

docs/source/html_builder.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@
1515

1616

1717
class MypyHTMLBuilder(StandaloneHTMLBuilder):
18+
strict_file: Path
1819
def __init__(self, app: Sphinx, env: BuildEnvironment) -> None:
1920
super().__init__(app, env)
2021
self._ref_to_doc = {}
22+
self.strict_file = Path(self.outdir) / "strict_list.rst"
2123
self._add_strict_list()
2224

2325
def write_doc(self, docname: str, doctree: document) -> None:
2426
super().write_doc(docname, doctree)
2527
self._ref_to_doc.update({_id: docname for _id in doctree.ids})
2628

2729
def _add_strict_list(self) -> None:
28-
p = Path(self.outdir).parent.parent / "source" / "strict_list.rst"
2930
strict_flags: list[str] = []
3031
process_options(["-c", "pass"], list_to_fill_with_strict_flags=strict_flags)
3132
strict_part = ", ".join(f":option:`{s} <mypy {s}>`" for s in strict_flags)
@@ -36,7 +37,7 @@ def _add_strict_list(self) -> None:
3637
or len(strict_part) > 2000
3738
):
3839
raise ValueError(f"{strict_part=}, which doesn't look right (by a simple heuristic).")
39-
p.write_text(strict_part)
40+
self.strict_file.write_text(strict_part)
4041

4142
def _verify_error_codes(self) -> None:
4243
from mypy.errorcodes import error_codes
@@ -72,6 +73,7 @@ def _write_ref_redirector(self) -> None:
7273
def finish(self) -> None:
7374
super().finish()
7475
self._write_ref_redirector()
76+
self.strict_file.unlink()
7577

7678

7779
def setup(app: Sphinx) -> dict[str, Any]:

0 commit comments

Comments
 (0)