8000 Type annotation add_subplot for projection="3d" by stefanv · Pull Request #29341 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Type annotation add_subplot for projection="3d" #29341

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 2, 2025
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/matplotlib/figure.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Callable, Hashable, Iterable, Sequence
import os
from typing import Any, IO, Literal, TypeVar, overload
from typing import Any, IO, Literal, TypeVar, overload, TYPE_CHECKING

import numpy as np
from numpy.typing import ArrayLike
Expand All @@ -25,6 +25,9 @@ from matplotlib.lines import Line2D
from matplotlib.patches import Rectangle, Patch
from matplotlib.text import Text
from matplotlib.transforms import Affine2D, Bbox, BboxBase, Transform
if TYPE_CHECKING:
Copy link
Member

Choose a reason for hiding this comment

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

Actually, this guard is not needed in .pyi files, because they are only used for tyoechecking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, removed

from mpl_toolkits.mplot3d import Axes3D

from .typing import ColorType, HashableList

_T = TypeVar("_T")
Expand Down Expand Up @@ -87,6 +90,8 @@ class FigureBase(Artist):

# TODO: docstring indicates SubplotSpec a valid arg, but none of the listed signatures appear to be that
@overload
def add_subplot(self, *args, projection: Literal["3d"], **kwargs) -> Axes3D: ...
@overload
def add_subplot(
self, nrows: int, ncols: int, index: int | tuple[int, int], **kwargs
) -> Axes: ...
Expand Down
Loading
0