Skip to content

Commit

Permalink
Resolve more mypy errors. (#811)
Browse files Browse the repository at this point in the history
* Redefined variables for type security.

* Redefined variables in `_get_segments` for type safety.

* Delete unnecessary `Union`.
  • Loading branch information
knutnergaard authored Dec 6, 2024
1 parent 7eba408 commit 61cd68d
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Lib/fontParts/base/contour.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
List,
Optional,
Tuple,
Type,
TypeVar,
Union,
)
Expand Down Expand Up @@ -65,8 +66,8 @@ class BaseContour(
"""

segmentClass = None
bPointClass = None
segmentClass: Optional[Type[BaseSegment]] = None
bPointClass: Optional[Type[BaseBPoint]] = None

def _reprContents(self) -> List[str]:
contents = []
Expand Down Expand Up @@ -935,10 +936,10 @@ def _get_segments(self) -> Tuple[BaseSegment, ...]:
for points in segments:
if self.segmentClass is None:
raise TypeError("segmentClass cannot be None.")
segment = self.segmentClass()
segment._setPoints(points)
self._setContourInSegment(segment)
wrapped.append(segment)
pointSegment = self.segmentClass()
pointSegment._setPoints(points)
self._setContourInSegment(pointSegment)
wrapped.append(pointSegment)
return tuple(wrapped)

def __getitem__(self, index: int) -> BaseSegment:
Expand Down

0 comments on commit 61cd68d

Please sign in to comment.