-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add typing for internal helpers #26367
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from collections.abc import Callable, Generator, Mapping, Sequence | ||
from typing import Any, Iterable, TypeVar, overload | ||
|
||
from numpy.typing import NDArray | ||
|
||
from .deprecation import ( # noqa: re-exported API | ||
deprecated as deprecated, | ||
warn_deprecated as warn_deprecated, | ||
rename_parameter as rename_parameter, | ||
delete_parameter as delete_parameter, | ||
make_keyword_only as make_keyword_only, | ||
deprecate_method_override as deprecate_method_override, | ||
deprecate_privatize_attribute as deprecate_privatize_attribute, | ||
suppress_matplotlib_deprecation_warning as suppress_matplotlib_deprecation_warning, | ||
MatplotlibDeprecationWarning as MatplotlibDeprecationWarning, | ||
) | ||
|
||
_T = TypeVar("_T") | ||
|
||
class classproperty(Any): | ||
def __init__( | ||
self, | ||
fget: Callable[[_T], Any], | ||
fset: None = ..., | ||
fdel: None = ..., | ||
doc: str | None = None, | ||
): ... | ||
@overload | ||
def __get__(self, instance: None, owner: None) -> classproperty: ... | ||
@overload | ||
def __get__(self, instance: object, owner: type[object]) -> Any: ... | ||
@property | ||
def fget(self) -> Callable[[_T], Any]: ... | ||
|
||
def check_isinstance( | ||
types: type | tuple[type | None, ...], /, **kwargs: Any | ||
) -> None: ... | ||
def check_in_list( | ||
values: Sequence[Any], /, *, _print_supported_values: bool = ..., **kwargs: Any | ||
) -> None: ... | ||
def check_shape(shape: tuple[int | None, ...], /, **kwargs: NDArray) -> None: ... | ||
def check_getitem(mapping: Mapping[Any, Any], /, **kwargs: Any) -> Any: ... | ||
def caching_module_getattr(cls: type) -> Callable[[str], Any]: ... | ||
@overload | ||
def define_aliases( | ||
alias_d: dict[str, list[str]], cls: None = ... | ||
) -> Callable[[type[_T]], type[_T]]: ... | ||
@overload | ||
def define_aliases(alias_d: dict[str, list[str]], cls: type[_T]) -> type[_T]: ... | ||
def select_matching_signature( | ||
funcs: list[Callable], *args: Any, **kwargs: Any | ||
) -> Any: ... | ||
def nargs_error(name: str, takes: int | str, given: int) -> TypeError: ... | ||
def kwarg_error(name: str, kw: str | Iterable[str]) -> TypeError: ... | ||
def recursive_subclasses(cls: type) -> Generator[type, None, None]: ... | ||
def warn_external( | ||
message: str | Warning, category: type[Warning] | None = ... | ||
) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from collections.abc import Callable | ||
import contextlib | ||
from typing import Any, TypedDict, TypeVar, overload | ||
from typing_extensions import ( | ||
ParamSpec, # < Py 3.10 | ||
Unpack, # < Py 3.11 | ||
) | ||
|
||
_P = ParamSpec("_P") | ||
_R = TypeVar("_R") | ||
_T = TypeVar("_T") | ||
|
||
class MatplotlibDeprecationWarning(DeprecationWarning): ... | ||
|
||
class DeprecationKwargs(TypedDict, total=False): | ||
message: str | ||
alternative: str | ||
pending: bool | ||
obj_type: str | ||
addendum: str | ||
removal: str | ||
|
||
class NamedDeprecationKwargs(DeprecationKwargs, total=False): | ||
name: str | ||
|
||
def warn_deprecated(since: str, **kwargs: Unpack[NamedDeprecationKwargs]) -> None: ... | ||
def deprecated( | ||
since: str, **kwargs: Unpack[NamedDeprecationKwargs] | ||
) -> Callable[[_T], _T]: ... | ||
|
||
class deprecate_privatize_attribute(Any): | ||
def __init__(self, since: str, **kwargs: Unpack[NamedDeprecationKwargs]): ... | ||
def __set_name__(self, owner: type[object], name: str) -> None: ... | ||
|
||
DECORATORS: dict[Callable, Callable] = ... | ||
|
||
@overload | ||
def rename_parameter( | ||
since: str, old: str, new: str, func: None = ... | ||
) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ... | ||
@overload | ||
def rename_parameter( | ||
since: str, old: str, new: str, func: Callable[_P, _R] | ||
) -> Callable[_P, _R]: ... | ||
|
||
class _deprecated_parameter_class: ... | ||
|
||
_deprecated_parameter: _deprecated_parameter_class | ||
|
||
@overload | ||
def delete_parameter( | ||
since: str, name: str, func: None = ..., **kwargs: Unpack[DeprecationKwargs] | ||
) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ... | ||
@overload | ||
def delete_parameter( | ||
since: str, name: str, func: Callable[_P, _R], **kwargs: Unpack[DeprecationKwargs] | ||
) -> Callable[_P, _R]: ... | ||
@overload | ||
def make_keyword_only( | ||
since: str, name: str, func: None = ... | ||
) -> Callable[[Callable[_P, _R]], Callable[_P, _R]]: ... | ||
@overload | ||
def make_keyword_only( | ||
since: str, name: str, func: Callable[_P, _R] | ||
) -> Callable[_P, _R]: ... | ||
def deprecate_method_override( | ||
method: Callable[_P, _R], | ||
obj: object | type, | ||
*, | ||
allow_empty: bool = ..., | ||
since: str, | ||
**kwargs: Unpack[NamedDeprecationKwargs] | ||
) -> Callable[_P, _R]: ... | ||
def suppress_matplotlib_deprecation_warning() -> ( | ||
contextlib.AbstractContextManager[None] | ||
): ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.