Bug summary
Type checkers complain when one uses a function that returns None as the parameter of FuncAnimation. However, when blit=False, the return value of the function is ignored.
Code for reproduction
import matplotlib.pyplot as plt
from matplotlib import rc
from matplotlib.animation import FuncAnimation
rc("animation", html="jshtml")
fig, ax = plt.subplots()
def update(frame: int) -> None:
ax.plot([0, 1], [frame, frame])
FuncAnimation(fig, update, range(10))
Actual outcome
MyPy says Argument 2 to "FuncAnimation" has incompatible type "Callable[[int], None]"; expected "Callable[..., Iterable[Artist]]", but the code executes without problems.
Expected outcome
No MyPy error.
Additional information
I think is possible to allow functions that return arbitrary object by combining overload and Literal[True] / Literal[False] for the blit argument.
Operating system
Any
Matplotlib Version
3.10.0
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
pip
Bug summary
Type checkers complain when one uses a function that returns
Noneas the parameter ofFuncAnimation. However, whenblit=False, the return value of the function is ignored.Code for reproduction
Actual outcome
MyPy says
Argument 2 to "FuncAnimation" has incompatible type "Callable[[int], None]"; expected "Callable[..., Iterable[Artist]]", but the code executes without problems.Expected outcome
No MyPy error.
Additional information
I think is possible to allow functions that return arbitrary
objectby combiningoverloadandLiteral[True]/Literal[False]for theblitargument.Operating system
Any
Matplotlib Version
3.10.0
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
pip