Mark stub-only private symbols as @type_check_only in third-party stubs (#14545)

This commit is contained in:
Brian Schubert
2025-08-08 11:29:48 +02:00
committed by GitHub
parent a358dc24e8
commit 81c8fcb2e6
131 changed files with 334 additions and 147 deletions
+2 -1
View File
@@ -1,5 +1,5 @@
from collections.abc import Iterable
from typing import Any, Literal, Protocol, TypeVar
from typing import Any, Literal, Protocol, TypeVar, type_check_only
from typing_extensions import TypeAlias, deprecated
from matplotlib.axes import Axes
@@ -17,6 +17,7 @@ __all__ = ["displot", "histplot", "kdeplot", "ecdfplot", "rugplot", "distplot"]
_T = TypeVar("_T")
_OneOrPair: TypeAlias = _T | tuple[_T, _T]
@type_check_only
class _Fit(Protocol):
def fit(self, a: ArrayLike) -> tuple[ArrayLike, ...]: ...
def pdf(self, x: ArrayLike, *params: ArrayLike) -> ArrayLike: ...
+2 -1
View File
@@ -1,5 +1,5 @@
from collections.abc import Callable
from typing import Any, Literal, Protocol
from typing import Any, Literal, Protocol, type_check_only
from typing_extensions import TypeAlias
import numpy as np
@@ -9,6 +9,7 @@ __all__ = ["gaussian_kde"]
# define a "Gaussian KDE" protocol so that we can also pass `scipy.stats.gaussian_kde` to
# functions that expect it without adding a dependency on scipy
@type_check_only
class _GaussianKDELike(Protocol):
dataset: NDArray[np.float64]
def __init__(self, dataset: ArrayLike, bw_method: Any | None = ..., weights: ArrayLike | None = ...) -> None: ...