Skip to content

Commit ec6e391

Browse files
committed
Improve documentation of __init__ and update
Convey that `other` is an optional positional-only argument more clearly by mentioning two signatures for both. Remove keyword arguments from the signature since they are ignored.
1 parent f2493fb commit ec6e391

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

docs/documentation.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -112,16 +112,17 @@ unless annotated with a message about working differently in the future.
112112
d["baz"] = 3.14
113113
func(d)
114114
115-
.. method:: __init__(other: dict | Iterable[Sequence[Any]], **kwargs)
115+
.. method:: __init__(other: Iterable[Sequence[Any]] | Mapping[Any, Any], /)
116+
__init__()
116117

117118
Initialise a new sorted dictionary with the keys and values from ``other``. ``other`` may be omitted, in which
118119
case, the sorted dictionary will be left empty.
119120

120121
.. details:: This method may work differently in the future.
121122
:class: critical
122123

123-
``kwargs`` is reserved for future use and currently ignored. This behaviour is not stable and may change
124-
without a major version bump.
124+
Keyword arguments are accepted but currently ignored: they are reserved for future use. This behaviour is not
125+
stable and may change without a major version bump.
125126

126127
.. property:: key_type
127128
:type: type | None
@@ -699,22 +700,23 @@ unless annotated with a message about working differently in the future.
699700
d[1.1] = ("racecar",)
700701
d.setdefault(float("nan"))
701702

702-
.. method:: update(other: dict | Iterable[Sequence[Any]], **kwargs)
703+
.. method:: update(other: Iterable[Sequence[Any]] | Mapping[Any, Any], /)
704+
update()
703705

704706
Update the sorted dictionary with the keys and values from ``other``. ``other`` may be omitted, in which case,
705707
this does nothing.
706708

707709
.. details:: This method may work differently in the future.
708710
:class: critical
709711

710-
``kwargs`` is reserved for future use and currently ignored. This behaviour is not stable and may change
711-
without a major version bump.
712+
Keyword arguments are accepted but currently ignored: they are reserved for future use. This behaviour is not
713+
stable and may change without a major version bump.
712714

713715
The rough Python equivalent of the logic written in C++ is as follows.
714716

715717
.. code-block:: python
716718
717-
def update(self, other, **kwargs):
719+
def update(self, other):
718720
if hasattr(other, "keys"):
719721
for key in other:
720722
self[key] = other[key]

0 commit comments

Comments
 (0)