8000 Merge pull request #28031 from ksunden/findobj_overload · matplotlib/matplotlib@2bdba84 · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2bdba84

Browse files
authored
Merge pull request #28031 from ksunden/findobj_overload
Be more specific in findobj return type
2 parents 6474934 + 01f1e9a commit 2bdba84

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/matplotlib/artist.pyi

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ from .transforms import (
1515
import numpy as np
1616

1717
from collections.abc import Callable, Iterable
18-
from typing import Any, NamedTuple, TextIO, overload
18+
from typing import Any, NamedTuple, TextIO, overload, TypeVar
1919
from numpy.typing import ArrayLike
2020

21+
_T_Artist = TypeVar("_T_Artist", bound=Artist)
22+
2123
def allow_rasterization(draw): ...
2224

2325
class _XYPair(NamedTuple):
@@ -128,11 +130,21 @@ class Artist:
128130
def update(self, props: dict[str, Any]) -> list[Any]: ...
129131
def _internal_update(self, kwargs: Any) -> list[Any]: ...
130132
def set(self, **kwargs: Any) -> list[Any]: ...
133+
134+
@overload
131135
def findobj(
132136
self,
133-
match: None | Callable[[Artist], bool] | type[Artist] = ...,
137+
match: None | Callable[[Artist], bool] = ...,
134138
include_self: bool = ...,
135139
) -> list[Artist]: ...
140+
141+
@overload
142+
def findobj(
143+
self,
144+
match: type[_T_Artist],
145+
include_self: bool = ...,
146+
) -> list[_T_Artist]: ...
147+
136148
def get_cursor_data(self, event: MouseEvent) -> Any: ...
137149
def format_cursor_data(self, data: Any) -> str: ...
138150
def get_mouseover(self) -> bool: ...

0 commit comments

Comments
 (0)
0