googlefonts / googlefonts/glyphsLib

Hints for properties in `Glyphs3-merge` branch

Open
#1,075 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
201
Forks
56
Avg merge
17m
Merged PRs (30d)
1

Description

Hey @schriftgestalt!

I am trying the latest version you pushed a couple of weeks ago, and I cannot find the hints you mentioned during our last meeting.

Consider this snippet:

```python
from glyphsLib import GSFont

from dinamo.mastering.constants import TESTS_FONTS_FOLDER

if __name__ == "__main__":
gs_font = GSFont("font.glyphs")
for glyph in gs_font.glyphs:
print(glyph)

```

The language server considers `gs_font.glyphs` as `Any` (default for an attribute without hints)

Image

Instead if I annotate explicitly the property in `classes.py`

```python
glyphs: list[GSGlyph] = property(
lambda self: FontGlyphsProxy(self),
lambda self, value: FontGlyphsProxy(self).setter(value),
)
```

The language server is able to pick up the right class definition.

Image

Contributor guide

Open the contributing guide

Research direction

Start in classes.py, focusing on the GSFont.glyphs property and its FontGlyphsProxy and GSGlyph types. Compare the current declaration with the explicit annotation shown in the issue, then check the example's gs_font.glyphs expression in a Python language server. Done means the property resolves to the appropriate typed class instead of Any.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
developer-experience
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.