Skip to content

Commit 8ed2716

Browse files
committed
docs: Minor fixes
1 parent 60cbb5f commit 8ed2716

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

docs/extensions/built-in/unpack-typeddict.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# `unpack`
1+
# `unpack_typeddict`
22

3-
The `unpack_typeddict` extension adds support for [`Unpack`][typing.Unpack] and [`TypedDict`][typing.TypedDict] from the standard library. When enabled, it will add an `__init__` method to typed dictionaries, and expand `**kwargs: Unpack[...]` (the ellipsis being a [typed dict][typing.TypedDict] class) in function signatures to the relevant parameters, using the typed dict attributes. The extension will also update any Parameters section in the function docstring, to reflect the signature update.
3+
The `unpack_typeddict` extension adds support for [`Unpack`][typing.Unpack] and [`TypedDict`][typing.TypedDict] from the standard library. When enabled, it will add an `__init__` method to typed dictionaries, and expand `**kwargs: Unpack[...]` (the ellipsis being a [typed dict][typing.TypedDict] class) in function signatures to the relevant parameters, using the typed dict attributes or added signature. The extension will also update any Parameters section in the function docstring, to reflect the signature update.
44

55
Example:
66

@@ -34,10 +34,10 @@ With the `unpack_typeddict` extension enabled, the data loaded by Griffe will be
3434

3535
```python
3636
class GreetKwargs(TypedDict):
37-
# Attributes removed from Griffe data (not from runtime class).
37+
# Attributes removed from Griffe data.
3838

39-
# Added by the `typeddict` extension to Griffe data (not to the runtime class):
40-
def __init__(self, name: str, shout: bool) -> None:
39+
# Added by the extension to Griffe data (not to the runtime class):
40+
def __init__(self, *, name: str, shout: bool) -> None:
4141
"""
4242
Parameters:
4343
name: The name of a person to greet.

src/griffe/_internal/extensions/unpack_typeddict.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def _update_docstring(func: Function, parameters: Iterable[Parameter], kwparam:
2626
# Create a parameters section if none exists.
2727
params_section = DocstringSectionParameters([])
2828
func.docstring.parsed.append(params_section)
29-
# Add entries for all TypedDict attributes.
29+
# Add entries for all parameters.
3030
for param in parameters:
3131
if param.name != "self":
3232
params_section.value.append(
@@ -82,7 +82,7 @@ def on_class(self, *, cls: Class, **kwargs: Any) -> None: # noqa: ARG002
8282
cls.del_member(attr.name)
8383

8484
def on_function(self, *, func: Function, **kwargs: Any) -> None: # noqa: ARG002
85-
"""Replace `**kwargs: Unpack[TypedDict]` parameters with the actual TypedDict attributes."""
85+
"""Expand `**kwargs: Unpack[TypedDict]` in function signatures."""
8686
# Find any `**kwargs: Unpack[TypedDict]` parameter.
8787
for parameter in func.parameters:
8888
if parameter.kind is ParameterKind.var_keyword:

0 commit comments

Comments
 (0)