Browse Source

PolygonalCircuit & subclasses: fix constructor's argument type hint

Fabian Peter Hammerle 3 years ago
parent
commit
91af7a603a
2 changed files with 6 additions and 8 deletions
  1. 2 0
      CHANGELOG.md
  2. 4 8
      freesurfer_surface/__init__.py

+ 2 - 0
CHANGELOG.md

@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
 
 ## [Unreleased]
+### Fixed
+- type hints
 
 ## [1.1.1] - 2020-10-18
 ### Fixed

+ 4 - 8
freesurfer_surface/__init__.py

@@ -106,8 +106,7 @@ class Vertex(numpy.ndarray):
         return "{}({})".format(type(self).__name__, self.__format_coords())
 
     def distance_mm(
-        self,
-        others: typing.Union["Vertex", typing.Iterable["Vertex"], numpy.ndarray],
+        self, others: typing.Union["Vertex", typing.Iterable["Vertex"], numpy.ndarray]
     ) -> numpy.ndarray:
         if isinstance(others, Vertex):
             others = others.reshape((1, 3))
@@ -115,10 +114,7 @@ class Vertex(numpy.ndarray):
 
 
 class PolygonalCircuit:
-
-    _VERTEX_INDICES_TYPE = typing.Tuple[int]
-
-    def __init__(self, vertex_indices: _VERTEX_INDICES_TYPE):
+    def __init__(self, vertex_indices: typing.Iterable[int]):
         self._vertex_indices = tuple(vertex_indices)
         assert all(isinstance(idx, int) for idx in self._vertex_indices)
 
@@ -163,7 +159,7 @@ class PolygonalCircuit:
 
 
 class LineSegment(PolygonalCircuit):
-    def __init__(self, indices: PolygonalCircuit._VERTEX_INDICES_TYPE):
+    def __init__(self, indices: typing.Iterable[int]):
         super().__init__(indices)
         assert len(self.vertex_indices) == 2
 
@@ -172,7 +168,7 @@ class LineSegment(PolygonalCircuit):
 
 
 class Triangle(PolygonalCircuit):
-    def __init__(self, indices: PolygonalCircuit._VERTEX_INDICES_TYPE):
+    def __init__(self, indices: typing.Iterable[int]):
         super().__init__(indices)
         assert len(self.vertex_indices) == 3