Skip to content

Commit

Permalink
First run of ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
benkiel committed Nov 2, 2024
1 parent f8a9975 commit ee7dcb5
Show file tree
Hide file tree
Showing 68 changed files with 2,869 additions and 4,121 deletions.
3 changes: 2 additions & 1 deletion Lib/fontParts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
except ImportError:
try:
from setuptools_scm import get_version

__version__ = get_version()
except ImportError:
__version__ = 'unknown'
__version__ = "unknown"
46 changes: 23 additions & 23 deletions Lib/fontParts/base/anchor.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
from fontTools.misc import transform
from fontParts.base import normalizers
from fontParts.base.base import (
BaseObject, TransformationMixin, InterpolationMixin, SelectionMixin,
PointPositionMixin, IdentifierMixin, dynamicProperty, reference
BaseObject,
TransformationMixin,
InterpolationMixin,
SelectionMixin,
PointPositionMixin,
IdentifierMixin,
dynamicProperty,
reference,
)
from fontParts.base.compatibility import AnchorCompatibilityReporter
from fontParts.base.color import Color
from fontParts.base.deprecated import DeprecatedAnchor, RemovedAnchor


class BaseAnchor(
BaseObject,
TransformationMixin,
DeprecatedAnchor,
RemovedAnchor,
PointPositionMixin,
InterpolationMixin,
SelectionMixin,
IdentifierMixin
):

BaseObject,
TransformationMixin,
DeprecatedAnchor,
RemovedAnchor,
PointPositionMixin,
InterpolationMixin,
SelectionMixin,
IdentifierMixin,
):
"""
An anchor object. This object is almost always
created with :meth:`BaseGlyph.appendAnchor`.
Expand All @@ -42,12 +47,7 @@ def _reprContents(self):
# Copy
# ----

copyAttributes = (
"x",
"y",
"name",
"color"
)
copyAttributes = ("x", "y", "name", "color")

# -------
# Parents
Expand Down Expand Up @@ -104,7 +104,7 @@ def _get_font(self):
>>> anchor.x
100
>>> anchor.x = 101
"""
""",
)

def _get_base_x(self):
Expand Down Expand Up @@ -147,7 +147,7 @@ def _set_x(self, value):
>>> anchor.y
100
>>> anchor.y = 101
"""
""",
)

def _get_base_y(self):
Expand Down Expand Up @@ -194,7 +194,7 @@ def _set_y(self, value):
>>> anchor.index
0
"""
""",
)

def _get_base_index(self):
Expand Down Expand Up @@ -225,7 +225,7 @@ def _get_index(self):
>>> anchor.name
'my anchor'
>>> anchor.name = None
"""
""",
)

def _get_base_name(self):
Expand Down Expand Up @@ -272,7 +272,7 @@ def _set_name(self, value):
>>> anchor.color
None
>>> anchor.color = (1, 0, 0, 0.5)
"""
""",
)

def _get_base_color(self):
Expand Down
7 changes: 3 additions & 4 deletions Lib/fontParts/base/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# Builtins

T = TypeVar('T')
T = TypeVar("T")
CollectionType = Union[List[T], Tuple[T, ...]]
IntFloatType = Union[int, float]

Expand All @@ -28,14 +28,13 @@
ColorType = Tuple[IntFloatType, IntFloatType, IntFloatType, IntFloatType]
CoordinateType = Tuple[IntFloatType, IntFloatType]
FactorType = Union[IntFloatType, Tuple[IntFloatType, IntFloatType]]
InterpolatableType = TypeVar('InterpolatableType', bound='Interpolatable')
InterpolatableType = TypeVar("InterpolatableType", bound="Interpolatable")
KerningKeyType = Tuple[str, str]
KerningDictType = Dict[KerningKeyType, IntFloatType]
ReverseComponentMappingType = Dict[str, Tuple[str, ...]]
ScaleType = Tuple[IntFloatType, IntFloatType]
TransformationMatrixType = Tuple[
IntFloatType, IntFloatType, IntFloatType,
IntFloatType, IntFloatType, IntFloatType
IntFloatType, IntFloatType, IntFloatType, IntFloatType, IntFloatType, IntFloatType
]


Expand Down
73 changes: 39 additions & 34 deletions Lib/fontParts/base/bPoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@
SelectionMixin,
IdentifierMixin,
dynamicProperty,
reference
reference,
)
from fontParts.base.errors import FontPartsError
from fontParts.base import normalizers
from fontParts.base.deprecated import DeprecatedBPoint, RemovedBPoint
from fontParts.base.annotations import (
CoordinateType,
TransformationMatrixType
)
from fontParts.base.annotations import CoordinateType, TransformationMatrixType

if TYPE_CHECKING:
from fontParts.base.contour import BaseContour
from fontParts.base.font import BaseFont
Expand All @@ -26,12 +24,14 @@
from fontParts.base.segment import BaseSegment


class BaseBPoint(BaseObject,
TransformationMixin,
SelectionMixin,
DeprecatedBPoint,
IdentifierMixin,
RemovedBPoint):
class BaseBPoint(
BaseObject,
TransformationMixin,
SelectionMixin,
DeprecatedBPoint,
IdentifierMixin,
RemovedBPoint,
):
"""Represent the basis for a bPoint object."""

def _reprContents(self) -> List[str]:
Expand Down Expand Up @@ -138,7 +138,7 @@ def _get_base_nextSegment(self) -> Optional[BaseSegment]:
>>> contour = bPoint.contour
"""
""",
)

def _get_contour(self) -> Optional[BaseContour]:
Expand Down Expand Up @@ -170,7 +170,7 @@ def _set_contour(self, contour: Optional[BaseContour]) -> None:
>>> glyph = bPoint.glyph
"""
""",
)

def _get_glyph(self) -> Optional[BaseGlyph]:
Expand All @@ -193,7 +193,7 @@ def _get_glyph(self) -> Optional[BaseGlyph]:
>>> layer = bPoint.layer
"""
""",
)

def _get_layer(self) -> Optional[BaseLayer]:
Expand All @@ -216,7 +216,7 @@ def _get_layer(self) -> Optional[BaseLayer]:
>>> font = bPoint.font
"""
""",
)

def _get_font(self) -> Optional[BaseFont]:
Expand All @@ -238,7 +238,7 @@ def _get_font(self) -> Optional[BaseFont]:
:return: a :ref:`type-coordianate` representing the anchor point of the bPoint.
"""
""",
)

def _get_base_anchor(self) -> CoordinateType:
Expand Down Expand Up @@ -300,7 +300,7 @@ def _set_anchor(self, value: CoordinateType) -> None:
:return: A :ref:`type-coordinate` representing the incoming
off-curve of the bPoin.
"""
""",
)

def _get_base_bcpIn(self) -> CoordinateType:
Expand Down Expand Up @@ -356,9 +356,9 @@ def _set_bcpIn(self, value: CoordinateType) -> None:
x, y = absoluteBCPIn(self.anchor, value)
segment = self._segment
if segment.type == "move" and value != (0, 0):
raise FontPartsError(("Cannot set the bcpIn for the first "
"point in an open contour.")
)
raise FontPartsError(
("Cannot set the bcpIn for the first " "point in an open contour.")
)

offCurves = segment.offCurve
if offCurves:
Expand Down Expand Up @@ -387,7 +387,7 @@ def _set_bcpIn(self, value: CoordinateType) -> None:
:return: A :ref:`type-coordinate` representing the outgoing
off-curve of the bPoin.
"""
""",
)

def _get_base_bcpOut(self) -> CoordinateType:
Expand Down Expand Up @@ -444,9 +444,9 @@ def _set_bcpOut(self, value: CoordinateType) -> None:
segment = self._segment
nextSegment = self._nextSegment
if nextSegment.type == "move" and value != (0, 0):
raise FontPartsError(("Cannot set the bcpOut for the last "
"point in an open contour.")
)
raise FontPartsError(
("Cannot set the bcpOut for the last " "point in an open contour.")
)
else:
offCurves = nextSegment.offCurve
if offCurves:
Expand Down Expand Up @@ -482,7 +482,7 @@ def _set_bcpOut(self, value: CoordinateType) -> None:
:return: A :class:`str` representing the type of the bPoint.
"""
""",
)

def _get_base_type(self) -> str:
Expand Down Expand Up @@ -526,8 +526,7 @@ def _get_type(self) -> str:
bType = "corner"

if bType is None:
raise FontPartsError("A %s point can not be converted to a bPoint."
% typ)
raise FontPartsError("A %s point can not be converted to a bPoint." % typ)
return bType

def _set_type(self, value: str) -> None:
Expand Down Expand Up @@ -578,7 +577,7 @@ def _set_type(self, value: str) -> None:
>>> bPoint.index
0
"""
""",
)

def _get_base_index(self) -> Optional[int]:
Expand Down Expand Up @@ -656,14 +655,20 @@ def round(self) -> None:
"""
x, y = self.anchor
self.anchor = (normalizers.normalizeVisualRounding(x),
normalizers.normalizeVisualRounding(y))
self.anchor = (
normalizers.normalizeVisualRounding(x),
normalizers.normalizeVisualRounding(y),
)
x, y = self.bcpIn
self.bcpIn = (normalizers.normalizeVisualRounding(x),
normalizers.normalizeVisualRounding(y))
self.bcpIn = (
normalizers.normalizeVisualRounding(x),
normalizers.normalizeVisualRounding(y),
)
x, y = self.bcpOut
self.bcpOut = (normalizers.normalizeVisualRounding(x),
normalizers.normalizeVisualRounding(y))
self.bcpOut = (
normalizers.normalizeVisualRounding(x),
normalizers.normalizeVisualRounding(y),
)


def relativeBCPIn(anchor: CoordinateType, BCPIn: CoordinateType) -> CoordinateType:
Expand Down
Loading

0 comments on commit ee7dcb5

Please sign in to comment.