[ufoLib] Add description and annotation to fontInfoAttributes value data#4063
[ufoLib] Add description and annotation to fontInfoAttributes value data#4063KrZ-W wants to merge 2 commits into
Conversation
…value data Add `description` (from UFO specification) and `annotation` (Python type hint string) fields to all entries in `fontInfoAttributesVersion2ValueData` and `fontInfoAttributesVersion3ValueData`. This enables better documentation and type hinting of font info attributes for IDE autocomplete and static analysis. Closes fonttools#3862
Lines with added description/annotation fields that exceeded line length limit are now properly wrapped by black. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Is there a benefit to defining annotations as strings rather than If Strings are indeed most appropriate, I guess testing them for validity would be in order. |
|
Good question! The issue author (@anthrotype) gave specific guidance in #3862 to use string annotations and to avoid String annotations have a few practical benefits here:
That said, I agree that validation of the string format could be useful. Happy to add that if the maintainers want it — perhaps a simple check that each annotation string is a valid Python type expression. |
|
@KrZ-W Sorry, the link to the issue authored by @anthrotype you're referencing appears to be wrong. Could you edit at your convenience? |
|
What issue did I author? |
Summary
Adds
descriptionandannotationfields to all entries infontInfoAttributesVersion2ValueDataandfontInfoAttributesVersion3ValueData, as discussed in #3862.typingtypes (Union,List,Dict,Any)This enables better documentation and type hinting of font info attributes for IDE autocomplete and static analysis.
Design decisions per maintainer guidance
dict(a=b)constructor style (per @justvanrossum's comment)typingmodule types (notannotated-types)"integerList"types that per UFO spec may contain floats (e.g. PostScript blues/stems) use"List[Union[int, float]]"; pure-integer lists (flags, ranges) use"List[int]"Test results
All 299 existing ufoLib tests pass. The 5 pre-existing failures in GLIF2/glifLib tests (unrelated to this change) remain unchanged.
Closes #3862