Skip to content

Commit

Permalink
Improve some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jab committed Mar 20, 2022
1 parent 452b027 commit 8bb8d96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions bidict/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from ._typing import KT, VT, MISSING, OKT, OVT, IterItems, MapOrIterItems


# Disable some pyright strict diagnostics that are not helpful in this file:
# Disable pyright strict diagnostics causing many false positives or that are just not helpful in this file:
# pyright: reportPrivateUsage=false, reportUnknownArgumentType=false, reportUnknownMemberType=false, reportUnknownVariableType=false, reportUnnecessaryIsInstance=false


Expand Down Expand Up @@ -162,6 +162,9 @@ def __init__(self, *args: MapOrIterItems[KT, VT], **kw: VT) -> None:
if args or kw:
self._update(get_arg(*args), kw, rbof=False)

# If Python ever adds support for higher-kinded types, `inverse` could use them, e.g.
# def inverse(self: BT[KT, VT]) -> BT[VT, KT]:
# Ref: https://github.com/python/typing/issues/548#issuecomment-621571821
@property
def inverse(self) -> 'BidictBase[VT, KT]':
"""The inverse of this bidirectional mapping instance."""
Expand Down Expand Up @@ -492,7 +495,7 @@ def _init_from(self, other: MapOrIterItems[KT, VT]) -> None:
# If other is a bidict, use its existing backing inverse mapping, otherwise
# other could be a generator that's now exhausted, so invert self._fwdm on the fly.
inv = other.inverse if isinstance(other, BidictBase) else inverted(self._fwdm)
self._invm.update(inv) # pyright: ignore
self._invm.update(inv) # pyright: ignore # https://github.com/jab/bidict/pull/242#discussion_r824223403

#: Used for the copy protocol.
#: *See also* the :mod:`copy` module
Expand Down
2 changes: 1 addition & 1 deletion bidict/_bidict.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def popitem(self) -> t.Tuple[KT, VT]:
del self._invm[val]
return key, val

@t.overload # type: ignore [override]
@t.overload # type: ignore [override] # https://github.com/jab/bidict/pull/242#discussion_r825464731
def update(self, __m: t.Mapping[KT, VT], **kw: VT) -> None: ...
@t.overload
def update(self, __i: IterItems[KT, VT], **kw: VT) -> None: ...
Expand Down

0 comments on commit 8bb8d96

Please sign in to comment.