Skip to content

Annotate and document compatibility.py#822

Open
knutnergaard wants to merge 3 commits intorobotools:v1from
knutnergaard:compatibility
Open

Annotate and document compatibility.py#822
knutnergaard wants to merge 3 commits intorobotools:v1from
knutnergaard:compatibility

Conversation

@knutnergaard
Copy link
Contributor

@knutnergaard knutnergaard commented Mar 11, 2025

@benkiel b0efc71 results in the folllowing mypy errors:

glyph.py:2903: error: Argument 1 to "list" has incompatible type "set[tuple[Optional[str], int]]"; expected "Iterable[str]"  [arg-type]
glyph.py:2908: error: Argument 1 to "list" has incompatible type "set[tuple[Optional[str], int]]"; expected "Iterable[str]"  [arg-type]
Found 2 errors in 1 file (checked 24 source files)

This can be most easily solved by casting set[tuple[Optional[str], int]] to str, but I'm not sure if that's appropriate.

Also, should this module be documented?

@knutnergaard knutnergaard marked this pull request as ready for review January 30, 2026 02:41
@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

❌ Patch coverage is 76.71233% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.25%. Comparing base (cdafc80) to head (bba2109).
⚠️ Report is 1 commits behind head on v1.

Files with missing lines Patch % Lines
Lib/fontParts/base/compatibility.py 74.24% 16 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               v1     #822      +/-   ##
==========================================
- Coverage   76.51%   76.25%   -0.26%     
==========================================
  Files          42       42              
  Lines        6459     6558      +99     
  Branches      966      987      +21     
==========================================
+ Hits         4942     5001      +59     
- Misses       1277     1296      +19     
- Partials      240      261      +21     
Files with missing lines Coverage Δ
Lib/fontParts/base/annotations.py 89.65% <100.00%> (+0.36%) ⬆️
Lib/fontParts/base/glyph.py 74.97% <100.00%> (-0.10%) ⬇️
Lib/fontParts/base/compatibility.py 36.68% <74.24%> (-0.24%) ⬇️

... and 19 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@knutnergaard
Copy link
Contributor Author

To clarify the mypy errors above, the confusion stems from GlyphCompatibilityReporter treating self.guidelinesMissingFromGlyph1 and self.guidelinesMissingFromGlyph2 as list[str], e.g.:

for name in self.guidelinesMissingFromGlyph1:
text = self.reportDifferences(
object1Name=self.glyph2Name,
subObjectName="guideline",
subObjectID=name,
object2Name=self.glyph1Name,
)

At the same time BaseGlyph._isConpatible is treating the same attributes as list[tuple[str | None, int]]:

for source, names in ((self, selfGuidelines),
(other, otherGuidelines)):
for i, guideline in enumerate(source.guidelines):
names.append((guideline.name, i))
guidelines1 = set(selfGuidelines)
guidelines2 = set(otherGuidelines)
if len(guidelines1.difference(guidelines2)) != 0:
reporter.warning = True
reporter.guidelinesMissingFromGlyph2 = list(
guidelines1.difference(guidelines2))
if len(guidelines2.difference(guidelines1)) != 0:
reporter.warning = True
reporter.guidelinesMissingFromGlyph1 = list(
guidelines2.difference(guidelines1))

Depending on the actual intention, one viable option to solve this is to remove the index before casting to list in BaseGlyph._isConpatible, e.g.:

reporter.guidelinesMissingFromGlyph2 = [
    name
    for name, _ in guidelines1.difference(guidelines2)
    if name is not None
    ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant