1515
1616
1717class 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
7779def setup (app : Sphinx ) -> dict [str , Any ]:
0 commit comments