Skip to content

Commit

Permalink
refactor type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
mozman committed Feb 22, 2024
1 parent 1e49ccc commit 65c40b3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/ezdxf/math/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __str__(self) -> str:
return f"ConstructionCircle({self.center}, {self.radius})"

@staticmethod
def from_3p(p1: UVec, p2: UVec, p3: UVec) -> "ConstructionCircle":
def from_3p(p1: UVec, p2: UVec, p3: UVec) -> ConstructionCircle:
"""Creates a circle from three points, all points have to be compatible
to :class:`Vec2` class.
"""
Expand All @@ -52,7 +52,7 @@ def from_3p(p1: UVec, p2: UVec, p3: UVec) -> "ConstructionCircle":
return ConstructionCircle(center, center.distance(_p1))

@property
def bounding_box(self) -> "BoundingBox2d":
def bounding_box(self) -> BoundingBox2d:
"""2D bounding box of circle as :class:`BoundingBox2d` object."""
rvec = Vec2((self.radius, self.radius))
return BoundingBox2d((self.center - rvec, self.center + rvec))
Expand Down
18 changes: 9 additions & 9 deletions src/ezdxf/math/line.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2010-2022, Manfred Moitzi
# Copyright (c) 2010-2024, Manfred Moitzi
# License: MIT License
from __future__ import annotations
from typing import Optional
Expand Down Expand Up @@ -108,7 +108,7 @@ def __repr__(self) -> str:
"angle={0.angle:.5f})".format(self)
)

def is_parallel(self, other: "ConstructionRay") -> bool:
def is_parallel(self, other: ConstructionRay) -> bool:
"""Returns ``True`` if rays are parallel."""
if self._is_vertical:
return other._is_vertical
Expand All @@ -119,7 +119,7 @@ def is_parallel(self, other: "ConstructionRay") -> bool:
# guards above guarantee that no slope is None
return math.isclose(self._slope, other._slope, abs_tol=ABS_TOL) # type: ignore

def intersect(self, other: "ConstructionRay") -> Vec2:
def intersect(self, other: ConstructionRay) -> Vec2:
"""Returns the intersection point as ``(x, y)`` tuple of `self` and
`other`.
Expand Down Expand Up @@ -158,7 +158,7 @@ def intersect(self, other: "ConstructionRay") -> Vec2:
y = ray1.yof(x)
return Vec2((x, y))

def orthogonal(self, location: UVec) -> "ConstructionRay":
def orthogonal(self, location: UVec) -> ConstructionRay:
"""Returns orthogonal ray at `location`."""
return ConstructionRay(location, angle=self.angle + HALF_PI)

Expand Down Expand Up @@ -188,7 +188,7 @@ def xof(self, y: float) -> float:
else:
raise ArithmeticError

def bisectrix(self, other: "ConstructionRay") -> "ConstructionRay":
def bisectrix(self, other: ConstructionRay) -> ConstructionRay:
"""Bisectrix between `self` and `other`."""
intersection = self.intersect(other)
alpha = (self.angle + other.angle) / 2.0
Expand Down Expand Up @@ -260,7 +260,7 @@ def length(self) -> float:
"""Returns length of line."""
return (self.end - self.start).magnitude

def midpoint(self) -> "Vec2":
def midpoint(self) -> Vec2:
"""Returns mid point of line."""
return self.start.lerp(self.end)

Expand All @@ -279,8 +279,8 @@ def inside_bounding_box(self, point: UVec) -> bool:
return self.bounding_box.inside(point)

def intersect(
self, other: "ConstructionLine", abs_tol: float = TOLERANCE
) -> Optional["Vec2"]:
self, other: ConstructionLine, abs_tol: float = TOLERANCE
) -> Optional[Vec2]:
"""Returns the intersection point of to lines or ``None`` if they have
no intersection point.
Expand All @@ -297,7 +297,7 @@ def intersect(
)

def has_intersection(
self, other: "ConstructionLine", abs_tol: float = TOLERANCE
self, other: ConstructionLine, abs_tol: float = TOLERANCE
) -> bool:
"""Returns ``True`` if has intersection with `other` line."""
return self.intersect(other, abs_tol=abs_tol) is not None
Expand Down

0 comments on commit 65c40b3

Please sign in to comment.