Skip to content

Commit

Permalink
🔧 Deprecate unused add_need kwargs (#1224)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
chrisjsewell authored Aug 21, 2024
1 parent ff4ae90 commit 87d51d5
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions sphinx_needs/api/need.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import hashlib
import os
import re
import warnings
from contextlib import contextmanager
from typing import Any, Iterator

Expand Down Expand Up @@ -34,6 +35,8 @@

logger = get_logger(__name__)

_deprecated_kwargs = {"constraints_passed", "links_string", "hide_tags", "hide_status"}


def add_need(
app: Sphinx,
Expand All @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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
#############################################################################################
Expand Down Expand Up @@ -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]:
"""
Expand All @@ -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 <a> tag.
"""
Expand All @@ -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,
Expand Down

0 comments on commit 87d51d5

Please sign in to comment.