Browse Source

PolygonalChain: fix type hints

Fabian Peter Hammerle 3 years ago
parent
commit
5a8812ec11
1 changed files with 9 additions and 4 deletions
  1. 9 4
      freesurfer_surface/__init__.py

+ 9 - 4
freesurfer_surface/__init__.py

@@ -185,10 +185,15 @@ class PolygonalChainsNotOverlapingError(ValueError):
 
 class PolygonalChain:
     def __init__(self, vertex_indices: typing.Iterable[int]):
-        self.vertex_indices = collections.deque(vertex_indices)  # type: Deque[int]
+        self.vertex_indices = collections.deque(
+            vertex_indices
+        )  # type: typing.Deque[int]
 
-    def __eq__(self, other: "PolygonalChain") -> bool:
-        return self.vertex_indices == other.vertex_indices
+    def __eq__(self, other: object) -> bool:
+        return (
+            isinstance(other, PolygonalChain)
+            and self.vertex_indices == other.vertex_indices
+        )
 
     def __repr__(self) -> str:
         return "PolygonalChain(vertex_indices={})".format(tuple(self.vertex_indices))
@@ -211,7 +216,7 @@ class PolygonalChain:
 
     def adjacent_vertex_indices(
         self, vertices_num: int = 2
-    ) -> typing.Iterable[typing.Tuple[int]]:
+    ) -> typing.Iterator[typing.Tuple[int, ...]]:
         return zip(
             *(
                 itertools.islice(self.vertex_indices, offset, len(self.vertex_indices))