From 12c0b949d1ab459862964a87d26752324201136f Mon Sep 17 00:00:00 2001 From: schriftgestalt Date: Thu, 21 Dec 2023 23:15:01 +0100 Subject: [PATCH] lint --- Lib/glyphsLib/builder/bracket_layers.py | 2 ++ Lib/glyphsLib/builder/builders.py | 2 +- Lib/glyphsLib/builder/features.py | 4 ++-- Lib/glyphsLib/builder/glyph.py | 1 - Lib/glyphsLib/builder/instances.py | 9 ++++----- tests/builder/__init__.py | 3 ++- tests/builder/custom_params_test.py | 1 - tests/builder/instances_test.py | 4 +++- tests/glyphs3_test.py | 1 - 9 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Lib/glyphsLib/builder/bracket_layers.py b/Lib/glyphsLib/builder/bracket_layers.py index 80c62a914..9fa546bc0 100644 --- a/Lib/glyphsLib/builder/bracket_layers.py +++ b/Lib/glyphsLib/builder/bracket_layers.py @@ -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 @@ -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. diff --git a/Lib/glyphsLib/builder/builders.py b/Lib/glyphsLib/builder/builders.py index f7b38f003..5d2bad45d 100644 --- a/Lib/glyphsLib/builder/builders.py +++ b/Lib/glyphsLib/builder/builders.py @@ -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 diff --git a/Lib/glyphsLib/builder/features.py b/Lib/glyphsLib/builder/features.py index 3d1b817de..d7707ef45 100644 --- a/Lib/glyphsLib/builder/features.py +++ b/Lib/glyphsLib/builder/features.py @@ -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'. diff --git a/Lib/glyphsLib/builder/glyph.py b/Lib/glyphsLib/builder/glyph.py index d87367687..8ec98ba49 100644 --- a/Lib/glyphsLib/builder/glyph.py +++ b/Lib/glyphsLib/builder/glyph.py @@ -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, diff --git a/Lib/glyphsLib/builder/instances.py b/Lib/glyphsLib/builder/instances.py index 2e7cebefb..98a0189c1 100644 --- a/Lib/glyphsLib/builder/instances.py +++ b/Lib/glyphsLib/builder/instances.py @@ -18,7 +18,7 @@ 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, @@ -26,7 +26,6 @@ InstanceType, PropertiesProxy, WEIGHT_CODES, - PROPERTIES_WHITELIST ) from .constants import ( GLYPHS_PREFIX, @@ -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 @@ -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) diff --git a/tests/builder/__init__.py b/tests/builder/__init__.py index a6f338c53..583059441 100644 --- a/tests/builder/__init__.py +++ b/tests/builder/__init__.py @@ -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. @@ -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)) diff --git a/tests/builder/custom_params_test.py b/tests/builder/custom_params_test.py index 2b67e7a1a..34556c0d0 100644 --- a/tests/builder/custom_params_test.py +++ b/tests/builder/custom_params_test.py @@ -17,7 +17,6 @@ import copy import os import unittest -import pytest from textwrap import dedent from unittest import mock diff --git a/tests/builder/instances_test.py b/tests/builder/instances_test.py index a06228041..af3ab68ee 100644 --- a/tests/builder/instances_test.py +++ b/tests/builder/instances_test.py @@ -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 @@ -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 diff --git a/tests/glyphs3_test.py b/tests/glyphs3_test.py index 60029f07a..590f0d18d 100644 --- a/tests/glyphs3_test.py +++ b/tests/glyphs3_test.py @@ -1,4 +1,3 @@ -import pytest import os import tempfile import glyphsLib