Skip to content

Commit

Permalink
refactor: Remove get_call_keyword_arguments utility function, as it…
Browse files Browse the repository at this point in the history
… is implemented with a single line and creates a cyclic depdendency with expressions
  • Loading branch information
pawamoy committed Feb 12, 2024
1 parent 9614c83 commit 35cf170
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 19 deletions.
3 changes: 1 addition & 2 deletions src/griffe/agents/nodes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from griffe.agents.nodes._docstrings import get_docstring
from griffe.agents.nodes._imports import relative_to_absolute
from griffe.agents.nodes._names import get_instance_names, get_name, get_names
from griffe.agents.nodes._parameters import get_call_keyword_arguments, get_parameters
from griffe.agents.nodes._parameters import get_parameters
from griffe.agents.nodes._runtime import ObjectNode
from griffe.agents.nodes._values import get_value, safe_get_value
from griffe.enumerations import ObjectKind
Expand Down Expand Up @@ -62,7 +62,6 @@ def __getattr__(name: str) -> Any:
"get__all__",
"get_annotation",
"get_base_class",
"get_call_keyword_arguments",
"get_condition",
"get_docstring",
"get_expression",
Expand Down
19 changes: 2 additions & 17 deletions src/griffe/agents/nodes/_parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,14 @@
from __future__ import annotations

from itertools import zip_longest
from typing import TYPE_CHECKING, Any, Iterable
from typing import TYPE_CHECKING, Iterable

from griffe.enumerations import ParameterKind
from griffe.logger import get_logger

if TYPE_CHECKING:
import ast

from griffe.dataclasses import Class, Module


logger = get_logger(__name__)


Expand Down Expand Up @@ -85,16 +82,4 @@ def get_parameters(node: ast.arguments) -> list[tuple[str, ast.AST, ParameterKin
return parameters


def get_call_keyword_arguments(node: ast.Call, parent: Module | Class) -> dict[str, Any]:
"""Get the list of keyword argument names and values from a Call node.
Parameters:
node: The node to extract the keyword arguments from.
Returns:
The keyword argument names and values.
"""
return {kw.arg: safe_get_expression(kw.value, parent) for kw in node.keywords if kw.arg}


__all__ = ["get_call_keyword_arguments"]
__all__ = ["get_parameters"]

0 comments on commit 35cf170

Please sign in to comment.