From 5ed1e932410e4dfdf4453666d6ca5709192da73e Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Thu, 28 Nov 2024 13:02:33 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Add=20TypedDict=20for=20statuses?= =?UTF-8?q?/tags=20config?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sphinx_needs/config.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sphinx_needs/config.py b/sphinx_needs/config.py index c1afa03f8..d6e573815 100644 --- a/sphinx_needs/config.py +++ b/sphinx_needs/config.py @@ -236,6 +236,16 @@ class NeedExtraOption(TypedDict): """A description of the option.""" +class NeedStatusesOption(TypedDict): + name: str + description: NotRequired[str] + + +class NeedTagsOption(TypedDict): + name: str + description: NotRequired[str] + + @dataclass class NeedsSphinxConfig: """A wrapper around the Sphinx configuration, @@ -479,24 +489,14 @@ def functions(self) -> Mapping[str, NeedFunctionsType]: default=False, metadata={"rebuild": "html", "types": (bool,)} ) """Raise exceptions if a needextend filter does not match any needs.""" - statuses: list[dict[str, str]] = field( + statuses: list[NeedStatusesOption] = field( default_factory=list, metadata={"rebuild": "html", "types": ()} ) - """If given, only the defined status are allowed. - Values needed for each status: - * name - * description - Example: [{"name": "open", "description": "open status"}, {...}, {...}] - """ - tags: list[dict[str, str]] = field( + """If given, only the defined statuses are allowed.""" + tags: list[NeedTagsOption] = field( default_factory=list, metadata={"rebuild": "html", "types": (list,)} ) - """If given, only the defined tags are allowed. - Values needed for each tag: - * name - * description - Example: [{"name": "new", "description": "new needs"}, {...}, {...}] - """ + """If given, only the defined tags are allowed.""" css: str = field( default="modern.css", metadata={"rebuild": "html", "types": (str,)} )