Skip to content

Use decorator style properties #222

@lianghai

Description

@lianghai

Problem

Some recent changes (eg, #189) have created difficulties for Pylance/Pyright to infer that Font.kerning is of type Kerning:

Screen Shot 2022-06-17 at 15 45 41

See also a non-property for comparison:

Screen Shot 2022-06-17 at 15 45 24

Is it because that the property class isn’t generic? I tried to look into issue tickets in the Pylance and Pyright projects but haven’t found anything helpful.

Potential solution

Seems it works alright if we write the properties (eg, .kerning and .lib) in the decorator style:

Screen Shot 2022-06-17 at 15 54 31

To be clear, I don’t really understand type checkers enough to tell if the decorator method is an arbitrary workaround or a long term solution, and I certainly don’t want to make the maintainers to randomly patch ufoLib2 only for some specific type checkers’ temporary limitations…

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions