Closed
Description
Bug summary
The return type for add_subplots
with projection="3d"
should be Axes3D
.
The current implementation is:
@overload
def add_subplot(
self, nrows: int, ncols: int, index: int | tuple[int, int], **kwargs
) -> Axes: ...
@overload
def add_subplot(self, pos: int, **kwargs) -> Axes: ...
@overload
def add_subplot(self, ax: Axes, **kwargs) -> Axes: ...
@overload
def add_subplot(self, ax: SubplotSpec, **kwargs) -> Axes: ...
@overload
def add_subplot(self, **kwargs) -> Axes: ...
@overload
def subplots(
Code for reproduction
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d.axes3d import Axes3D
ax: Axes3D = plt.figure().add_subplot(projection="3d")
Actual outcome
Pyright complains:
error: Type "Axes" is not assignable to declared type "Axes3D"
"Axes" is not assignable to "Axes3D" (reportAssignmentType)
Expected outcome
No error.
Additional information
No response
Operating system
No response
Matplotlib Version
3.10.0
Matplotlib Backend
No response
Python version
No response
Jupyter version
No response
Installation
None
Metadata
Metadata
Assignees
Labels
No labels