Skip to content

Avoid deprecated typing hints #26212

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 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion lib/matplotlib/_path.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from typing import Sequence
from collections.abc import Sequence

import numpy as np

from .transforms import BboxBase

def affine_transform(points: np.ndarray, trans: np.ndarray) -> np.ndarray: ...
Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/cbook.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ from numpy.typing import ArrayLike

from typing import (
Any,
ContextManager,
Generic,
IO,
Literal,
Expand Down Expand Up @@ -68,7 +67,7 @@ def open_file_cm(
path_or_file: str | os.PathLike | IO,
mode: str = ...,
encoding: str | None = ...,
) -> ContextManager[IO]: ...
) -> contextlib.AbstractContextManager[IO]: ...
def is_scalar_or_string(val: Any) -> bool: ...
@overload
def get_sample_data(
Expand Down
10 changes: 4 additions & 6 deletions lib/matplotlib/pyplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,14 @@
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from collections.abc import Callable, Hashable, Iterable, Sequence
import datetime
import pathlib
import os
from typing import Any, BinaryIO, Literal

import PIL

from numpy.typing import ArrayLike
from typing import (
Any, BinaryIO, Callable, Hashable, Literal, Sequence, Iterable, Type
)

from matplotlib.axis import Tick
from matplotlib.axes._base import _AxesBase
Expand Down Expand Up @@ -229,7 +227,7 @@ def set_loglevel(*args, **kwargs) -> None:
@_copy_docstring_and_deprecators(Artist.findobj)
def findobj(
o: Artist | None = None,
match: Callable[[Artist], bool] | Type[Artist] | None = None,
match: Callable[[Artist], bool] | type[Artist] | None = None,
include_self: bool = True
) -> list[Artist]:
if o is None:
Expand Down Expand Up @@ -751,7 +749,7 @@ def figure(
# defaults to rc figure.edgecolor
edgecolor: ColorType | None = None,
frameon: bool = True,
FigureClass: Type[Figure] = Figure,
FigureClass: type[Figure] = Figure,
clear: bool = False,
**kwargs
) -> Figure:
Expand Down
4 changes: 2 additions & 2 deletions lib/matplotlib/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
The ``typing`` module and type stub files are considered provisional and may change
at any time without a deprecation period.
"""
from collections.abc import Sequence
from collections.abc import Hashable, Sequence
import pathlib
from typing import Any, Hashable, Literal, Union
from typing import Any, Literal, Union

from . import path
from ._enums import JoinStyle, CapStyle
Expand Down