X Tutup
Skip to content

fix FuncAnimation class#29968

Closed
lynashere wants to merge 10 commits intomatplotlib:mainfrom
lynashere:fix-FuncAnimation-class
Closed

fix FuncAnimation class#29968
lynashere wants to merge 10 commits intomatplotlib:mainfrom
lynashere:fix-FuncAnimation-class

Conversation

@lynashere
Copy link
Copy Markdown

PR summary

  • Why is this change necessary?

  • To ensure the update function passed to FuncAnimation matches expected signatures and avoids runtime errors.

  • What problem does it solve?

  • It prevents type errors and ensures the animation updates frames correctly without freezing or crashing.

  • What is the reasoning for this implementation?

  • FuncAnimation requires different update function return types depending on blit, typing must reflect this to satisfy static checkers and runtime behavior.

Closes #29960

pre-commit.ci autofix

PR checklist

@lynashere
Copy link
Copy Markdown
Author

pre-commit.ci autofix

Comment on lines +210 to +212
func: Callable[..., Optional[Iterable[Artist]]],
frames: Iterable | int | Callable[[], Generator] | None = ...,
init_func: Optional[Callable[[], Optional[Iterable[Artist]]]] = ...,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You can use just | None like the others, no need for Optional.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I see, thank you I didn't know that.

@lynashere
Copy link
Copy Markdown
Author

pre-commit.ci autofix

@tacaswell
Copy link
Copy Markdown
Member

Who's credentials is precommit using to push these commits? If they are the orgs we should turn that off as a security risk (if they are the users I am still worried, but I don't think there is anything we can/should do about it).

Copy link
Copy Markdown
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

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

Please do not merge until the discussion in the linked issue is resolved.

I do not think we should relax the typing in this way.

@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented Apr 28, 2025

Who's credentials is precommit using to push these commits? If they are the orgs we should turn that off as a security risk (if they are the users I am still worried, but I don't think there is anything we can/should do about it).

It's a GitHub App, with a mix of some read and some write permissions. You can find it in Settings->GitHub Apps.

@timhoffm
Copy link
Copy Markdown
Member

Let's not solve this by overload, as discussed here #29960 (comment). A simpler fix is #29984.

@Lynsoo anyway thanks for the contribution!

@timhoffm timhoffm closed this Apr 29, 2025
@lynashere lynashere deleted the fix-FuncAnimation-class branch April 30, 2025 18:56
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.

[Bug]: FuncAnimation function not typed properly

5 participants

X Tutup