Skip to content

[typing] Ok to add typing_extensions as dep for older Pythons? #2163

@madig

Description

@madig

I'm looking at adding typing to some parts of the code base (currently: pens) to make them nicer to work with in IDEs and mypy.

Example: looking at AbstractPointPen.addPoint, the segmentType can be one of a few strings or None. Python's typing.Literal covers that, but was added only in Python 3.8. For older Pythons, there's a backport package at https://pypi.org/project/typing-extensions/ that contains that type.

Another example is Protocol, which can be used to declare that a class implements some interface, but without necessarily deriving from some common base class. I suppose pens fit that description, but I'm not sure if there is some isinstance shenanigans going on somewhere outside fontTools?

Long story short, is it ok to add typing-extensions as a conditional dependency for Python < 3.8?

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