formatting with black to get lint to pass

This commit is contained in:
Colin M. Ford 2023-04-05 22:33:38 -04:00
parent 45d1d01f66
commit 9656e3faf1
2 changed files with 124 additions and 49 deletions

View File

@ -250,10 +250,12 @@ def test(glyphsets, glyphs=None, names=None, ignore_missing=False):
# m0idx should be the index of the first non-None item in allNodeTypes, # m0idx should be the index of the first non-None item in allNodeTypes,
# else give it the first index of None, which is likely 0 # else give it the first index of None, which is likely 0
m0idx = allNodeTypes.index(next((x for x in allNodeTypes if x is not None), None)) m0idx = allNodeTypes.index(
next((x for x in allNodeTypes if x is not None), None)
)
# m0 is the first non-None item in allNodeTypes, or the first item if all are None # m0 is the first non-None item in allNodeTypes, or the first item if all are None
m0 = allNodeTypes[m0idx] m0 = allNodeTypes[m0idx]
for i, m1 in enumerate(allNodeTypes[m0idx+1:]): for i, m1 in enumerate(allNodeTypes[m0idx + 1 :]):
if m1 is None: if m1 is None:
continue continue
if len(m0) != len(m1): if len(m0) != len(m1):
@ -303,10 +305,12 @@ def test(glyphsets, glyphs=None, names=None, ignore_missing=False):
# m0idx should be the index of the first non-None item in allVectors, # m0idx should be the index of the first non-None item in allVectors,
# else give it the first index of None, which is likely 0 # else give it the first index of None, which is likely 0
m0idx = allVectors.index(next((x for x in allVectors if x is not None), None)) m0idx = allVectors.index(
next((x for x in allVectors if x is not None), None)
)
# m0 is the first non-None item in allVectors, or the first item if all are None # m0 is the first non-None item in allVectors, or the first item if all are None
m0 = allVectors[m0idx] m0 = allVectors[m0idx]
for i, m1 in enumerate(allVectors[m0idx+1:]): for i, m1 in enumerate(allVectors[m0idx + 1 :]):
if m1 is None: if m1 is None:
continue continue
if len(m0) != len(m1): if len(m0) != len(m1):
@ -336,10 +340,12 @@ def test(glyphsets, glyphs=None, names=None, ignore_missing=False):
# m0idx should be the index of the first non-None item in allContourIsomorphisms, # m0idx should be the index of the first non-None item in allContourIsomorphisms,
# else give it the first index of None, which is likely 0 # else give it the first index of None, which is likely 0
m0idx = allContourIsomorphisms.index(next((x for x in allContourIsomorphisms if x is not None), None)) m0idx = allContourIsomorphisms.index(
next((x for x in allContourIsomorphisms if x is not None), None)
)
# m0 is the first non-None item in allContourIsomorphisms, or the first item if all are None # m0 is the first non-None item in allContourIsomorphisms, or the first item if all are None
m0 = allContourIsomorphisms[m0idx] m0 = allContourIsomorphisms[m0idx]
for i, m1 in enumerate(allContourIsomorphisms[m0idx+1:]): for i, m1 in enumerate(allContourIsomorphisms[m0idx + 1 :]):
if m1 is None: if m1 is None:
continue continue
if len(m0) != len(m1): if len(m0) != len(m1):
@ -397,7 +403,11 @@ def main(args=None):
help="Will not report glyphs missing from sparse masters as errors", help="Will not report glyphs missing from sparse masters as errors",
) )
parser.add_argument( parser.add_argument(
"inputs", metavar="FILE", type=str, nargs="+", help="Input a single DesignSpace/Glyphs file, or multiple TTF/UFO files" "inputs",
metavar="FILE",
type=str,
nargs="+",
help="Input a single DesignSpace/Glyphs file, or multiple TTF/UFO files",
) )
args = parser.parse_args(args) args = parser.parse_args(args)
@ -477,7 +487,7 @@ def main(args=None):
glyphset = font.getGlyphSet() glyphset = font.getGlyphSet()
else: else:
glyphset = font glyphset = font
glyphsets.append({k:glyphset[k] for k in glyphset.keys()}) glyphsets.append({k: glyphset[k] for k in glyphset.keys()})
if not glyphs: if not glyphs:
glyphs = set([gn for glyphset in glyphsets for gn in glyphset.keys()]) glyphs = set([gn for glyphset in glyphsets for gn in glyphset.keys()])
@ -489,7 +499,9 @@ def main(args=None):
for gn in diff: for gn in diff:
glyphset[gn] = None glyphset[gn] = None
problems = test(glyphsets, glyphs=glyphs, names=names, ignore_missing=args.ignore_missing) problems = test(
glyphsets, glyphs=glyphs, names=names, ignore_missing=args.ignore_missing
)
if not args.quiet: if not args.quiet:
if args.json: if args.json:

View File

@ -133,17 +133,37 @@ class InterpolatableTest(unittest.TestCase):
# without --ignore-missing # without --ignore-missing
problems = interpolatable_main(["--quiet"] + ttf_paths) problems = interpolatable_main(["--quiet"] + ttf_paths)
self.assertEqual(problems['a'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}]) self.assertEqual(
self.assertEqual(problems['s'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}]) problems["a"],
self.assertEqual(problems['edotabove'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}]) [{"type": "missing", "master": "SparseMasters-Medium"}]
self.assertEqual(problems['dotabovecomb'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}]) )
self.assertEqual(
problems["s"],
[{"type": "missing", "master": "SparseMasters-Medium"}]
)
self.assertEqual(
problems["edotabove"],
[{"type": "missing", "master": "SparseMasters-Medium"}],
)
self.assertEqual(
problems["dotabovecomb"],
[{"type": "missing", "master": "SparseMasters-Medium"}],
)
# normal order, with --ignore-missing # normal order, with --ignore-missing
self.assertIsNone(interpolatable_main(["--ignore-missing"] + ttf_paths)) self.assertIsNone(interpolatable_main(["--ignore-missing"] + ttf_paths))
# purposely putting the sparse master (medium) first # purposely putting the sparse master (medium) first
self.assertIsNone(interpolatable_main(["--ignore-missing"] + [ttf_paths[1]] + [ttf_paths[0]] + [ttf_paths[2]])) self.assertIsNone(
interpolatable_main(
["--ignore-missing"] + [ttf_paths[1]] + [ttf_paths[0]] + [ttf_paths[2]]
)
)
# purposely putting the sparse master (medium) last # purposely putting the sparse master (medium) last
self.assertIsNone(interpolatable_main(["--ignore-missing"] + [ttf_paths[0]] + [ttf_paths[2]] + [ttf_paths[1]])) self.assertIsNone(
interpolatable_main(
["--ignore-missing"] + [ttf_paths[0]] + [ttf_paths[2]] + [ttf_paths[1]]
)
)
def test_sparse_interpolatable_ufos(self): def test_sparse_interpolatable_ufos(self):
ttx_dir = self.get_test_input("master_ufo") ttx_dir = self.get_test_input("master_ufo")
@ -151,26 +171,58 @@ class InterpolatableTest(unittest.TestCase):
# without --ignore-missing # without --ignore-missing
problems = interpolatable_main(["--quiet"] + ufo_paths) problems = interpolatable_main(["--quiet"] + ufo_paths)
self.assertEqual(problems['a'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}]) self.assertEqual(
self.assertEqual(problems['s'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}]) problems["a"],
self.assertEqual(problems['edotabove'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}]) [{"type": "missing", "master": "SparseMasters-Medium"}]
self.assertEqual(problems['dotabovecomb'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}]) )
self.assertEqual(
problems["s"],
[{"type": "missing", "master": "SparseMasters-Medium"}]
)
self.assertEqual(
problems["edotabove"],
[{"type": "missing", "master": "SparseMasters-Medium"}],
)
self.assertEqual(
problems["dotabovecomb"],
[{"type": "missing", "master": "SparseMasters-Medium"}],
)
# normal order, with --ignore-missing # normal order, with --ignore-missing
self.assertIsNone(interpolatable_main(["--ignore-missing"] + ufo_paths)) self.assertIsNone(interpolatable_main(["--ignore-missing"] + ufo_paths))
# purposely putting the sparse master (medium) first # purposely putting the sparse master (medium) first
self.assertIsNone(interpolatable_main(["--ignore-missing"] + [ufo_paths[1]] + [ufo_paths[0]] + [ufo_paths[2]])) self.assertIsNone(
interpolatable_main(
["--ignore-missing"] + [ufo_paths[1]] + [ufo_paths[0]] + [ufo_paths[2]]
)
)
# purposely putting the sparse master (medium) last # purposely putting the sparse master (medium) last
self.assertIsNone(interpolatable_main(["--ignore-missing"] + [ufo_paths[0]] + [ufo_paths[2]] + [ufo_paths[1]])) self.assertIsNone(
interpolatable_main(
["--ignore-missing"] + [ufo_paths[0]] + [ufo_paths[2]] + [ufo_paths[1]]
)
)
def test_sparse_designspace(self): def test_sparse_designspace(self):
designspace_path = self.get_test_input("SparseMasters_ufo.designspace") designspace_path = self.get_test_input("SparseMasters_ufo.designspace")
problems = interpolatable_main(["--quiet", designspace_path]) problems = interpolatable_main(["--quiet", designspace_path])
self.assertEqual(problems['a'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}]) self.assertEqual(
self.assertEqual(problems['s'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}]) problems["a"],
self.assertEqual(problems['edotabove'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}]) [{"type": "missing", "master": "SparseMasters-Medium"}]
self.assertEqual(problems['dotabovecomb'], [{'type': 'missing', 'master': 'SparseMasters-Medium'}]) )
self.assertEqual(
problems["s"],
[{"type": "missing", "master": "SparseMasters-Medium"}]
)
self.assertEqual(
problems["edotabove"],
[{"type": "missing", "master": "SparseMasters-Medium"}],
)
self.assertEqual(
problems["dotabovecomb"],
[{"type": "missing", "master": "SparseMasters-Medium"}],
)
# normal order, with --ignore-missing # normal order, with --ignore-missing
self.assertIsNone(interpolatable_main(["--ignore-missing", designspace_path])) self.assertIsNone(interpolatable_main(["--ignore-missing", designspace_path]))
@ -179,15 +231,26 @@ class InterpolatableTest(unittest.TestCase):
glyphsapp_path = self.get_test_input("SparseMasters.glyphs") glyphsapp_path = self.get_test_input("SparseMasters.glyphs")
problems = interpolatable_main(["--quiet", glyphsapp_path]) problems = interpolatable_main(["--quiet", glyphsapp_path])
self.assertEqual(problems['a'], [{'type': 'missing', 'master': 'Sparse Masters-Medium'}]) self.assertEqual(
self.assertEqual(problems['s'], [{'type': 'missing', 'master': 'Sparse Masters-Medium'}]) problems["a"],
self.assertEqual(problems['edotabove'], [{'type': 'missing', 'master': 'Sparse Masters-Medium'}]) [{"type": "missing", "master": "Sparse Masters-Medium"}]
self.assertEqual(problems['dotabovecomb'], [{'type': 'missing', 'master': 'Sparse Masters-Medium'}]) )
self.assertEqual(
problems["s"],
[{"type": "missing", "master": "Sparse Masters-Medium"}]
)
self.assertEqual(
problems["edotabove"],
[{"type": "missing", "master": "Sparse Masters-Medium"}],
)
self.assertEqual(
problems["dotabovecomb"],
[{"type": "missing", "master": "Sparse Masters-Medium"}],
)
# normal order, with --ignore-missing # normal order, with --ignore-missing
self.assertIsNone(interpolatable_main(["--ignore-missing", glyphsapp_path])) self.assertIsNone(interpolatable_main(["--ignore-missing", glyphsapp_path]))
def test_interpolatable_varComposite(self): def test_interpolatable_varComposite(self):
input_path = self.get_test_input( input_path = self.get_test_input(
"..", "..", "ttLib", "data", "varc-ac00-ac01.ttf" "..", "..", "ttLib", "data", "varc-ac00-ac01.ttf"