Skip to content

Commit c82bbc9

Browse files
committed
Fix CI checks
1 parent 705f771 commit c82bbc9

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

multiaddr/multiaddr.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ def __init__(self, mapping: "Multiaddr") -> None:
2020
self._mapping = mapping
2121
super().__init__(mapping)
2222

23-
def __contains__(self, proto: object) -> bool:
24-
proto = self._mapping.registry.find(proto)
25-
return collections.abc.Sequence.__contains__(self, proto)
26-
27-
def __getitem__(self, idx: int | slice) -> Any | Sequence[Any]:
28-
if isinstance(idx, slice):
29-
return list(self)[idx]
30-
if idx < 0:
31-
idx = len(self) + idx
32-
for idx2, proto in enumerate(self):
33-
if idx2 == idx:
23+
def __contains__(self, value: object) -> bool:
24+
value = self._mapping.registry.find(value)
25+
return collections.abc.Sequence.__contains__(self, value)
26+
27+
def __getitem__(self, index: int | slice) -> Any | Sequence[Any]:
28+
if isinstance(index, slice):
29+
return list(self)[index]
30+
if index < 0:
31+
index = len(self) + index
32+
for index2, proto in enumerate(self):
33+
if index2 == index:
3434
return proto
3535
raise IndexError("Protocol list index out of range")
3636

@@ -52,23 +52,23 @@ def __init__(self, mapping: "Multiaddr") -> None:
5252
def __contains__(self, item: object) -> bool:
5353
if not isinstance(item, tuple) or len(item) != 2:
5454
return False
55-
proto, value = item
55+
proto, item = item
5656
proto = self._mapping.registry.find(proto)
57-
return collections.abc.Sequence.__contains__(self, (proto, value))
57+
return collections.abc.Sequence.__contains__(self, (proto, item))
5858

5959
@overload
60-
def __getitem__(self, idx: int) -> tuple[Any, Any]: ...
60+
def __getitem__(self, index: int) -> tuple[Any, Any]: ...
6161

6262
@overload
63-
def __getitem__(self, idx: slice) -> Sequence[tuple[Any, Any]]: ...
63+
def __getitem__(self, index: slice) -> Sequence[tuple[Any, Any]]: ...
6464

65-
def __getitem__(self, idx: int | slice) -> tuple[Any, Any] | Sequence[tuple[Any, Any]]:
66-
if isinstance(idx, slice):
67-
return list(self)[idx]
68-
if idx < 0:
69-
idx = len(self) + idx
65+
def __getitem__(self, index: int | slice) -> tuple[Any, Any] | Sequence[tuple[Any, Any]]:
66+
if isinstance(index, slice):
67+
return list(self)[index]
68+
if index < 0:
69+
index = len(self) + index
7070
for idx2, item in enumerate(self):
71-
if idx2 == idx:
71+
if idx2 == index:
7272
return item
7373
raise IndexError("Protocol item list index out of range")
7474

@@ -99,13 +99,13 @@ def __init__(self, mapping: "Multiaddr") -> None:
9999
def __contains__(self, value: object) -> bool:
100100
return collections.abc.Sequence.__contains__(self, value)
101101

102-
def __getitem__(self, idx: int | slice) -> Any | Sequence[Any]:
103-
if isinstance(idx, slice):
104-
return list(self)[idx]
105-
if idx < 0:
106-
idx = len(self) + idx
102+
def __getitem__(self, index: int | slice) -> Any | Sequence[Any]:
103+
if isinstance(index, slice):
104+
return list(self)[index]
105+
if index < 0:
106+
index = len(self) + index
107107
for idx2, value in enumerate(self):
108-
if idx2 == idx:
108+
if idx2 == index:
109109
return value
110110
raise IndexError("Protocol value list index out of range")
111111

0 commit comments

Comments
 (0)