Skip to content

Commit

Permalink
Ruff format codebase (#760)
Browse files Browse the repository at this point in the history
* update pyproject and add in github action for ruff

* initial ruff formatting

* Update pyproject.toml
  • Loading branch information
benkiel authored Nov 2, 2024
1 parent 5fa6f5c commit 33e45f2
Show file tree
Hide file tree
Showing 70 changed files with 2,975 additions and 4,152 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Ruff
on: [push, pull_request]
jobs:
ruff:
runs-on: ubuntu-latest

permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write

steps:
- uses: actions/checkout@v4
- uses: astral-sh/ruff-action@v1
with:
args: "format"
changed-files: "true"
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: 'Format fixes by ruff'
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
13 changes: 5 additions & 8 deletions Lib/fontParts/base/annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from fontTools.pens.pointPen import AbstractPointPen

# Generic
T = TypeVar('T')
T = TypeVar("T")

PairType = Tuple[T, T]
QuadrupleType = Tuple[T, T, T, T]
Expand Down Expand Up @@ -35,17 +35,14 @@
TransformationType = Union[IntFloatType, List[IntFloatType], PairType[IntFloatType]]

# Interpolation
InterpolatableType = TypeVar('InterpolatableType', bound='Interpolatable')
InterpolatableType = TypeVar("InterpolatableType", bound="Interpolatable")


class Interpolatable(Protocol):
"""Represent a protocol for interpolatable types."""

def __add__(self, other: InterpolatableType) -> InterpolatableType:
...
def __add__(self, other: InterpolatableType) -> InterpolatableType: ...

def __sub__(self, other: InterpolatableType) -> InterpolatableType:
...
def __sub__(self, other: InterpolatableType) -> InterpolatableType: ...

def __mul__(self, other: TransformationType) -> InterpolatableType:
...
def __mul__(self, other: TransformationType) -> InterpolatableType: ...
Loading

0 comments on commit 33e45f2

Please sign in to comment.