Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Convert FontEntry to a data class#20118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
tacaswell merged 2 commits intomatplotlib:masterfromQuLogic:fe-dc
May 14, 2021
Merged

Conversation

QuLogic
Copy link
Member

PR Summary

With Python 3.7, we now havedata classes. I'm not sure if we want to start moving towards those, so I just converted one small one for discussion purposes.

(Plus a little cleanup to drop a flake8 exception)

PR Checklist

  • Has pytest style unit tests (andpytest passes).
  • IsFlake 8 compliant (runflake8 on changed files to check).
  • [n/a] New features are documented, with examples if plot related.
  • Documentation is sphinx and numpydoc compliant (the docs shouldbuild without error).
  • Conforms to Matplotlib style conventions (installflake8-docstrings and runflake8 --docstring-convention=all).
  • [n/a] New features have an entry indoc/users/next_whats_new/ (follow instructions in README.rst there).
  • [?] API changes documented indoc/api/next_api_changes/ (follow instructions in README.rst there).

@QuLogicQuLogic added this to thev3.5.0 milestoneApr 30, 2021
Comment on lines -366 to -368
try:
self.size = str(float(size))
except ValueError:
self.size = size
Copy link
MemberAuthor

@QuLogicQuLogicApr 30, 2021
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Note this is only called in two places, always withsize='scalable', so there's no point to this conversion.

@anntzer
Copy link
Contributor

I would vaguely prefer using make_dataclass (as I did in#18517), possibly together withbases ornamespace, because I don't like type annotations, but perhaps I'm just being old and grumpy here...

tacaswell reacted with laugh emoji

@QuLogic
Copy link
MemberAuthor

I did so, though I'm not sure it's quite as nice.

@tacaswell
Copy link
Member

This appears to have actually broken the docs

/home/circleci/project/lib/matplotlib/font_manager.py:docstring of matplotlib.font_manager.afmFontProperty:25: WARNING: py:obj reference target not found: FontEntry/home/circleci/project/lib/matplotlib/font_manager.py:docstring of matplotlib.font_manager.ttfFontProperty:25: WARNING: py:obj reference target not found: FontEntry

@tacaswell
Copy link
Member

The explicit construction is probably a bit more resilient to future changes CPython, but I suspect the type annotation version is more readable.

On the other hand, we do not (to my knowledge) have any other type annotations in the code base and given that annotations are still in flux (see the discussion about PEP563) I see the reasoning to keep it that way.

@QuLogic
Copy link
MemberAuthor

Strange, it does appear to have a docstring; Sphinx just doesn't appear to collect it.

No need to split over multiple lines and align equals signs.
@QuLogic
Copy link
MemberAuthor

OK, I added an explicit entry for it, and that should fix the docs. I guess we could drop that if we switch to the class style.

Copy link
Member

@jklymakjklymak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I mean this is fine - I don't quite understand the point though. Why is this better than a normal class? It seems identical, but with an extra song and dance for the docstring?

@QuLogic
Copy link
MemberAuthor

Well, tbh, it was a more effective looking change when it was written with annotations. But really I want to get rid of more flake8 exceptions.

@tacaswelltacaswell merged commitb5a206e intomatplotlib:masterMay 14, 2021
@QuLogicQuLogic deleted the fe-dc branchMay 14, 2021 03:33
@QuLogicQuLogic removed the status: needs comment/discussionneeds consensus on next step labelMay 14, 2021
QuLogic added a commit to QuLogic/matplotlib that referenced this pull requestDec 1, 2023
When these were added inmatplotlib#20118, we had no type annotations, so it madesense to use the functional form. Now that we do, there's no reason notto use the class form.Also, as `FontEntry` has gained more methods, the functional form looksless clear.
@QuLogicQuLogic mentioned this pull requestDec 1, 2023
2 tasks
QuLogic added a commit to QuLogic/matplotlib that referenced this pull requestJan 13, 2024
When these were added inmatplotlib#20118, we had no type annotations, so it madesense to use the functional form. Now that we do, there's no reason notto use the class form.Also, as `FontEntry` has gained more methods, the functional form looksless clear.
QuLogic added a commit to QuLogic/matplotlib that referenced this pull requestJan 13, 2024
When these were added inmatplotlib#20118, we had no type annotations, so it madesense to use the functional form. Now that we do, there's no reason notto use the class form.Also, as `FontEntry` has gained more methods, the functional form looksless clear.
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jklymakjklymakjklymak left review comments

@anntzeranntzeranntzer approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.5.0
Development

Successfully merging this pull request may close these issues.

4 participants
@QuLogic@anntzer@tacaswell@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp