🔧 Narrow typing for Builder.build method (#12357)

This commit is contained in:
Chris Sewell 2024-06-17 12:44:04 +02:00 committed by GitHub
parent 799ae16a01
commit 1e297bb8c5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -6,7 +6,7 @@ import codecs
import pickle import pickle
import time import time
from os import path from os import path
from typing import TYPE_CHECKING, Any from typing import TYPE_CHECKING, Any, Literal
from docutils import nodes from docutils import nodes
from docutils.utils import DependencyList from docutils.utils import DependencyList
@ -298,9 +298,9 @@ class Builder:
self, self,
docnames: Iterable[str] | None, docnames: Iterable[str] | None,
summary: str | None = None, summary: str | None = None,
method: str = 'update', method: Literal['all', 'specific', 'update'] = 'update',
) -> None: ) -> None:
"""Main build method. """Main build method, usually called by a specific ``build_*`` method.
First updates the environment, and then calls First updates the environment, and then calls
:meth:`!write`. :meth:`!write`.
@ -537,7 +537,7 @@ class Builder:
self, self,
build_docnames: Iterable[str] | None, build_docnames: Iterable[str] | None,
updated_docnames: Sequence[str], updated_docnames: Sequence[str],
method: str = 'update', method: Literal['all', 'specific', 'update'] = 'update',
) -> None: ) -> None:
if build_docnames is None or build_docnames == ['__all__']: if build_docnames is None or build_docnames == ['__all__']:
# build_all # build_all

View File

@ -7,7 +7,7 @@ import time
from codecs import open from codecs import open
from collections import defaultdict from collections import defaultdict
from os import getenv, path, walk from os import getenv, path, walk
from typing import TYPE_CHECKING, Any from typing import TYPE_CHECKING, Any, Literal
from uuid import uuid4 from uuid import uuid4
from docutils import nodes from docutils import nodes
@ -261,7 +261,7 @@ class MessageCatalogBuilder(I18nBuilder):
self, self,
docnames: Iterable[str] | None, docnames: Iterable[str] | None,
summary: str | None = None, summary: str | None = None,
method: str = 'update', method: Literal['all', 'specific', 'update'] = 'update',
) -> None: ) -> None:
self._extract_from_template() self._extract_from_template()
super().build(docnames, summary, method) super().build(docnames, summary, method)