GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — MNT: Make get_default_filetype a classmethod by timhoffm · Pull Request #31867 · matplotlib/matplotlib

Conversation

@timhoffm

@timhoffm timhoffm commented Jun 9, 2026

Copy link
Copy Markdown
Member

FigureCanvasBase defines get_default_filetype as a class method, but all derived implementations overwrite this with an instance method. All implementations could even be static. But let's coerce to a classmethod for consistency and to not change the public API of FigureCanvasBase

matplotlib/lib/matplotlib/backend_bases.py

Lines 2294 to 2295 in 8747449

@classmethod
def get_default_filetype(cls):

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@timhoffm
MNT: Make get_default_filetype a classmethod
8de94b3
FigureCanvasBase defines get_default_filetype as a classmethod,
but all derived implementations overwrite this with an instance
method. All implementations could even be static. But let's
coerce to a classmethod for consistency and to not change the
public API of FigureCanvasBase
@github-actions github-actions Bot added backend: pgf backend: ps backend: pdf backend: svg labels Jun 9, 2026
@timhoffm timhoffm mentioned this pull request Jun 9, 2026
Add typing interface file and type hints for backends.backend_pdf #31854
Merged
1 of 5 tasks
@timhoffm timhoffm added this to the v3.12.0 milestone Jun 10, 2026
QuLogic
QuLogic approved these changes Jun 10, 2026
View reviewed changes
ksunden
ksunden approved these changes Jun 10, 2026
View reviewed changes
@ksunden
ksunden merged commit 0677cc8 into matplotlib:main Jun 10, 2026
41 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@QuLogic

QuLogic commented Jun 10, 2026

Copy link
Copy Markdown
Member

Oh, I just realized #31867 was merged already; should we not remove the ignore from the type hints as well?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ksunden

ksunden commented Jun 10, 2026

Copy link
Copy Markdown
Member

I think you were meaning to reference something else, that is the number for this...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@timhoffm
timhoffm deleted the mnt-get_default_filetype branch June 10, 2026 21:43
@timhoffm

timhoffm commented Jun 10, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

You likely mean #31854.

Yes,

matplotlib/lib/matplotlib/backends/backend_pdf.pyi

Lines 411 to 412 in 0677cc8

# FIXME: `get_default_filetype` does not inherit from `FigureCanvasBase` correctly
def get_default_filetype(cls) -> str: ... # type: ignore[override]
should be adapted a follow-up.

QuLogic and myzhang1029 reacted with thumbs up emoji
All reactions
  • 👍 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@myzhang1029

myzhang1029 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

You likely mean #31854.

Yes,

matplotlib/lib/matplotlib/backends/backend_pdf.pyi

Lines 411 to 412 in 0677cc8

# FIXME: `get_default_filetype` does not inherit from `FigureCanvasBase` correctly
def get_default_filetype(cls) -> str: ... # type: ignore[override]

should be adapted a follow-up.

I was just checking back at this PR. May I go ahead and do this? mypy seems happy now.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@myzhang1029 myzhang1029 mentioned this pull request Jun 12, 2026
MNT: add @classmethod and remove ignore post #31867 #31884
Merged
1 of 5 tasks
timhoffm pushed a commit that referenced this pull request Jun 12, 2026
@myzhang1029
MNT: add @classmethod and remove ignore post #31867
6af7e4c
timhoffm added a commit that referenced this pull request Jun 12, 2026
@timhoffm
Merge pull request #31884 from myzhang1029/types-31854-31867-followup
d421cec
MNT: add `@classmethod` and remove `ignore` post #31867
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@QuLogic QuLogic QuLogic approved these changes
@ksunden ksunden ksunden approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

backend: pdf backend: pgf backend: ps backend: svg

Projects

None yet

Milestone

v3.12.0

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@timhoffm @QuLogic @ksunden @myzhang1029
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.