8000 Blacken by benkiel · Pull Request #742 · robotools/fontParts · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Blacken #742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
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
62 changes: 35 additions & 27 deletions Lib/fontParts/base/bPoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
SelectionMixin,
IdentifierMixin,
dynamicProperty,
reference
reference,
)
from fontParts.base.errors import FontPartsError
from fontParts.base import normalizers
from fontParts.base.deprecated import DeprecatedBPoint, RemovedBPoint


class BaseBPoint(
BaseObject,
TransformationMixin,
SelectionMixin,
DeprecatedBPoint,
IdentifierMixin,
RemovedBPoint
):
BaseObject,
TransformationMixin,
SelectionMixin,
DeprecatedBPoint,
IdentifierMixin,
RemovedBPoint,
):

def _reprContents(self):
contents = [
Expand Down Expand Up @@ -197,9 +197,9 @@ def _set_bcpIn(self, value):
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.")
)
else:
offCurves = segment.offCurve
if offCurves:
Expand Down Expand Up @@ -251,9 +251,9 @@ def _set_bcpOut(self, value):
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 @@ -304,8 +304,7 @@ def _get_type(self):
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):
Expand All @@ -331,11 +330,14 @@ def _set_type(self, value):
# Identification
# --------------

index = dynamicProperty("index",
("The index of the bPoint within the ordered "
"list of the parent contour's bPoints. None "
"if the bPoint does not belong to a contour.")
)
index = dynamicProperty(
"index",
(
"The index of the bPoint within the ordered "
"list of the parent contour's bPoints. None "
"if the bPoint does not belong to a contour."
),
)

def _get_base_index(self):
if self.contour is None:
Expand Down Expand Up @@ -381,14 +383,20 @@ def round(self):
Round coordinates.
"""
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, BCPIn):
Expand Down
24 changes: 12 additions & 12 deletions Lib/fontParts/base/base.py
57AE
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
# Helpers
# -------

class dynamicProperty(object):

class dynamicProperty(object):
"""
This implements functionality that is very similar
to Python's built in property function, but makes
Expand Down Expand Up @@ -111,6 +111,7 @@ def interpolate(a, b, v):
# Base Objects
# ------------


class BaseObject(object):

# --------------
Expand Down Expand Up @@ -138,9 +139,7 @@ def __repr__(self):
else:
contents = ""
s = "<{className}{contents} at {address}>".format(
className=self.__class__.__name__,
contents=contents,
address=id(self)
className=self.__class__.__name__, contents=contents, address=id(self)
)
return s

Expand Down Expand Up @@ -228,8 +227,9 @@ def raiseNotImplementedError(self):
the base classes. So, it's here for convenience.
"""
raise NotImplementedError(
"The {className} subclass does not implement this method."
.format(className=self.__class__.__name__)
"The {className} subclass does not implement this method.".format(
className=self.__class__.__name__
)
)

# ---------------------
Expand Down Expand Up @@ -290,8 +290,7 @@ def items(self):
items = self._items()
if self.keyNormalizer is not None and self.valueNormalizer is not None:
values = [
(self.keyNormalizer.__func__(key),
self.valueNormalizer.__func__(value))
(self.keyNormalizer.__func__(key), self.valueNormalizer.__func__(value))
for (key, value) in items
]
return values
Expand Down Expand Up @@ -654,7 +653,8 @@ def isCompatible(self, other, cls):
raise TypeError(
"""Compatibility between an instance of %r and an \
instance of %r can not be checked."""
% (cls.__name__, other.__class__.__name__))
% (cls.__name__, other.__class__.__name__)
)
reporter = self.compatibilityReporterClass(self, other)
self._isCompatible(other, reporter)
return not reporter.fatal, reporter
Expand All @@ -680,7 +680,7 @@ class SelectionMixin(object):
>>> obj.selected
False
>>> obj.selected = True
"""
""",
)

def _get_base_selected(self):
Expand Down Expand Up @@ -733,7 +733,6 @@ def _setSelectedSubObjects(cls, subObjects, selected):


class PointPositionMixin(object):

"""
This adds a ``position`` attribute as a dyanmicProperty,
for use as a mixin with objects that have ``x`` and ``y``
Expand Down Expand Up @@ -784,7 +783,7 @@ class IdentifierMixin(object):

To request an identifier if it does not exist use
`object.getIdentifier()`
"""
""",
)

def _get_base_identifier(self):
Expand Down Expand Up @@ -834,6 +833,7 @@ def reference(obj):
# return weakref.ref(obj)
def wrapper():
return obj

return wrapper


Expand Down
13 changes: 4 additions & 9 deletions Lib/fontParts/base/color.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
class Color(tuple):

"""
An color object. This follows the :ref:`type-color`.
"""

def _get_r(self):
return self[0]

r = property(_get_r,
"The color's red component as :ref:`type-int-float`.")
r = property(_get_r, "The color's red component as :ref:`type-int-float`.")

def _get_g(self):
return self[1]

g = property(_get_g,
"The color's green component as :ref:`type-int-float`.")
g = property(_get_g, "The color's green component as :ref:`type-int-float`.")

def _get_b(self):
return self[2]

b = property(_get_b,
"The color's blue component as :ref:`type-int-float`.")
b = property(_get_b, "The color's blue component as :ref:`type-int-float`.")

def _get_a(self):
return self[3]

a = property(_get_a,
"The color's alpha component as :ref:`type-int-float`.")
a = property(_get_a, "The color's alpha component as :ref:`type-int-float`.")
Loading
Loading
0