Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
schriftgestalt committed Dec 22, 2023
1 parent eabc45a commit 12c0b94
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 13 deletions.
2 changes: 2 additions & 0 deletions Lib/glyphsLib/builder/bracket_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
GLYPHLIB_PREFIX,
)


def _bracket_info(layer, axes):
# Returns a region expressed as a {axis_tag: (min, max)} box
# (dictionary), once the axes have been computed
Expand Down Expand Up @@ -44,6 +45,7 @@ def _bracket_info(layer, axes):
info[axis.tag] = (axis_min, axis_max)
return info


def to_designspace_bracket_layers(self):
"""Extract bracket layers in a GSGlyph into free-standing UFO glyphs with
Designspace substitution rules.
Expand Down
2 changes: 1 addition & 1 deletion Lib/glyphsLib/builder/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def __init__(
self._font = None

@property
def font(self):
def font(self): # noqa: C901
"""Get the GSFont built from the UFOs + designspace."""
if self._font is not None:
return self._font
Expand Down
4 changes: 2 additions & 2 deletions Lib/glyphsLib/builder/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ def _is_manual_kern_feature(feature):
return feature.name == "kern" and not feature.automatic


def _to_ufo_features(
def _to_ufo_features( # noqa: C901
font: GSFont,
ufo: Font | None = None,
generate_GDEF: bool = False,
master: GSFontMaster | None = None,
expand_includes: bool = False,
) -> str: # noqa: C901
) -> str:
"""Convert GSFont features, including prefixes and classes, to UFO.
Optionally, build a GDEF table definition, excluding 'skip_export_glyphs'.
Expand Down
1 change: 0 additions & 1 deletion Lib/glyphsLib/builder/glyph.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
from .constants import (
GLYPHLIB_PREFIX,
GLYPHS_COLORS,
PUBLIC_PREFIX,
UFO2FT_COLOR_LAYER_MAPPING_KEY,
BRACKET_GLYPH_RE,
BRACKET_GLYPH_SUFFIX_RE,
Expand Down
9 changes: 4 additions & 5 deletions Lib/glyphsLib/builder/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@

from fontTools.varLib.models import piecewiseLinearMap

from glyphsLib.util import build_ufo_path, best_repr_list
from glyphsLib.util import build_ufo_path
from glyphsLib.classes import (
CustomParametersProxy,
GSCustomParameter,
GSInstance,
InstanceType,
PropertiesProxy,
WEIGHT_CODES,
PROPERTIES_WHITELIST
)
from .constants import (
GLYPHS_PREFIX,
Expand Down Expand Up @@ -173,7 +172,7 @@ def _to_properties(instance):
]


def _is_instance_included_in_family(self, instance:GSInstance):
def _is_instance_included_in_family(self, instance: GSInstance):
if not self._do_filter_instances_by_family:
return True
return instance.familyName == self.family_name
Expand Down Expand Up @@ -387,11 +386,11 @@ def apply_instance_data_to_ufo(ufo, instance, designspace):

try:
ufo.info.openTypeOS2WidthClass = instance.lib["openTypeOS2WidthClass"]
except:
except KeyError:
pass
try:
ufo.info.openTypeOS2WeightClass = instance.lib["openTypeOS2WeightClass"]
except:
except KeyError:
pass

glyphs_instance = InstanceDescriptorAsGSInstance(instance)
Expand Down
3 changes: 2 additions & 1 deletion tests/builder/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@



import filecmp
from pathlib import Path
import difflib


def diff_files(file1, file2):
"""Takes two file paths, compares the contents and returns a formatted diff
if there are any differences, an empty string otherwise.
Expand All @@ -15,5 +15,6 @@ def diff_files(file1, file2):
return "\n".join(difflib.unified_diff(left, right))
return ""


def diff_lists(list1, list2):
return "\n".join(difflib.unified_diff(list1, list2))
1 change: 0 additions & 1 deletion tests/builder/custom_params_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import copy
import os
import unittest
import pytest
from textwrap import dedent

from unittest import mock
Expand Down
4 changes: 3 additions & 1 deletion tests/builder/instances_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,12 @@ def test_glyphs3_mapping():
# Instance2: designspace 600 -> userspace 650
doc = glyphsLib.to_designspace(font)
# FIXME: (georg) mapping is not implied from the weightClass any more
#assert doc.axes[0].map == [(400, 200), (600, 650), (900, 800)]
# assert doc.axes[0].map == [(400, 200), (600, 650), (900, 800)]
assert doc.instances[0].location == {"Weight": 200}
assert doc.instances[1].location == {"Weight": 800}
assert doc.instances[2].location == {"Weight": 650}


def test_glyphs3_mapping_AxisLocation():
font = glyphsLib.GSFont(os.path.join(DATA, "Glyphs3InstancesAxisLocation.glyphs"))
# Instance1: designspace 200 -> userspace 400
Expand All @@ -204,6 +205,7 @@ def test_glyphs3_mapping_AxisLocation():
assert doc.instances[1].location == {"Weight": 800}
assert doc.instances[2].location == {"Weight": 650}


def test_glyphs3_instance_filtering():
font = glyphsLib.GSFont(os.path.join(DATA, "InstanceFamilyName-G3.glyphs"))
assert len(font.instances) == 6
Expand Down
1 change: 0 additions & 1 deletion tests/glyphs3_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import pytest
import os
import tempfile
import glyphsLib
Expand Down

0 comments on commit 12c0b94

Please sign in to comment.