From 87d51d5cf190167d7cf3c1ab11a6560ba6a862c0 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Wed, 21 Aug 2024 08:39:44 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Deprecate=20unused=20`add=5Fneed?= =?UTF-8?q?`=20kwargs=20(#1224)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously they were silently ignored, so this commit specifically checks for them and provides a warning. This can then be removed in a future version of sphinx-needs. --- sphinx_needs/api/need.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sphinx_needs/api/need.py b/sphinx_needs/api/need.py index 8b805443f..d9c88ce24 100644 --- a/sphinx_needs/api/need.py +++ b/sphinx_needs/api/need.py @@ -3,6 +3,7 @@ import hashlib import os import re +import warnings from contextlib import contextmanager from typing import Any, Iterator @@ -34,6 +35,8 @@ logger = get_logger(__name__) +_deprecated_kwargs = {"constraints_passed", "links_string", "hide_tags", "hide_status"} + def add_need( app: Sphinx, @@ -49,13 +52,9 @@ def add_need( status: str | None = None, tags: None | str | list[str] = None, constraints: None | str | list[str] = None, - constraints_passed: None | bool = None, - links_string: None | str | list[str] = None, delete: None | bool = False, jinja_content: None | bool = False, hide: bool = False, - hide_tags: bool = False, - hide_status: bool = False, collapse: None | bool = None, style: None | str = None, layout: None | str = None, @@ -135,11 +134,8 @@ def run(): :param tags: Tags as single string. :param constraints: Constraints as single, comma separated, string. :param constraints_passed: Contains bool describing if all constraints have passed - :param links_string: Links as single string. (Not used) :param delete: boolean value (Remove the complete need). :param hide: boolean value. - :param hide_tags: boolean value. (Not used with Sphinx-Needs >0.5.0) - :param hide_status: boolean value. (Not used with Sphinx-Needs >0.5.0) :param collapse: boolean value. :param style: String value of class attribute of node. :param layout: String value of layout definition to use @@ -149,6 +145,13 @@ def run(): :return: node """ + + if kwargs.keys() & _deprecated_kwargs: + warnings.warn( + "deprecated key found in kwargs", DeprecationWarning, stacklevel=1 + ) + kwargs = {k: v for k, v in kwargs.items() if k not in _deprecated_kwargs} + ############################################################################################# # Get environment ############################################################################################# @@ -624,7 +627,6 @@ def add_external_need( status: str | None = None, tags: str | None = None, constraints: str | None = None, - links_string: str | None = None, **kwargs: Any, ) -> list[nodes.Node]: """ @@ -644,7 +646,6 @@ def add_external_need( :param status: Status as string. :param tags: Tags as single string. :param constraints: constraints as single, comma separated string. - :param links_string: Links as single string. :param external_css: CSS class name as string, which is set for the tag. """ @@ -671,7 +672,6 @@ def add_external_need( status=status, tags=tags, constraints=constraints, - links_string=links_string, is_external=True, external_url=external_url, external_css=external_css,