Skip to content

Update type hints for font manager and extension - #26403

Merged
tacaswell merged 1 commit into
matplotlib:mainfrom
QuLogic:font-typing
Aug 2, 2023
Merged

tacaswell merged 1 commit into
matplotlib:mainfrom
QuLogic:font-typing

Conversation

@QuLogic

@QuLogic QuLogic commented Jul 28, 2023

Copy link
Copy Markdown
Member

PR summary

Several setters allow None, but are normalized so that the getter is not.

For ttf, the FontEntry weight may be an int instead of a str.

PR checklist

@QuLogic

QuLogic commented Jul 28, 2023

Copy link
Copy Markdown
Member Author

I'm confused why I'm getting:

lib/matplotlib/ft2font.pyi:5: error: Module "typing_extensions" has no attribute "Buffer"  [attr-defined]

because docs say that is in 4.6, for which I've bumped the requirements, and we've ended up with 4.7.1 installed. Maybe we need a newer mypy too?

@ksunden

ksunden commented Jul 28, 2023

Copy link
Copy Markdown
Member

Mypy uses a vendored version of typeshed, which was synced to include Buffer here

So yes, I think a newer version of mypy is needed for this (>=1.4.0)

Upgrading that will require ignoring the staticmethod problem that we pinned mypy for (which hasn't seen much traction upstream, though somebody else recently opened a similar issue, sooo)

@QuLogic

QuLogic commented Jul 28, 2023

Copy link
Copy Markdown
Member Author

Hmm, well we didn't have Buffer on there before; maybe we can leave that out until mypy is fixed.

@QuLogic
QuLogic marked this pull request as ready for review July 28, 2023 03:03
@QuLogic QuLogic mentioned this pull request Jul 28, 2023
1 task done
@tacaswell tacaswell added this to the v3.8.0 milestone Jul 28, 2023
@tacaswell
tacaswell merged commit ccad5ef into matplotlib:main Aug 2, 2023
@QuLogic
QuLogic deleted the font-typing branch August 2, 2023 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants