Skip to content

Commit 2a51312

Browse files
committed
Apply pyupgrade autofixes
1 parent 9c5664c commit 2a51312

File tree

512 files changed

+780
-890
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

512 files changed

+780
-890
lines changed

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,15 @@ select = [
3232
"FA", # flake8-future-annotations
3333
"I", # isort
3434
"PYI", # flake8-pyi
35+
"UP", # pyupgrade
3536
]
3637
ignore = [
3738
###
3839
# Rules we don't want or don't agree with
3940
###
41+
# Slower and more verbose https://github.com/astral-sh/ruff/issues/7871
42+
"UP038", # Use `X | Y` in `isinstance` call instead of `(X, Y)`
43+
4044
# Typeshed doesn't want complex or non-literal defaults, or long strings, for maintenance and testing reasons.
4145
# This doesn't affect us, let's have more complete stubs.
4246
"PYI011",

stubs/matplotlib/__init__.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import contextlib
2-
from typing import Generator, Literal
2+
from collections.abc import Generator
3+
from typing import Literal
34

45
import numpy as np
56
from packaging.version import parse as parse_version

stubs/matplotlib/_api/__init__.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import functools
2-
from typing import Any, Callable, Generator, Iterable, Type
2+
from collections.abc import Generator, Iterable
3+
from typing import Callable
34

45
from .deprecation import MatplotlibDeprecationWarning
56

@@ -19,5 +20,5 @@ def select_matching_signature(funcs: list[Callable], *args, **kwargs): ...
1920
def recursive_subclasses(cls) -> Generator: ...
2021
def warn_external(
2122
message: MatplotlibDeprecationWarning | PendingDeprecationWarning | str,
22-
category: None | Type[MatplotlibDeprecationWarning] = ...,
23+
category: None | type[MatplotlibDeprecationWarning] = ...,
2324
) -> None: ...

stubs/matplotlib/_api/deprecation.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import contextlib
2+
from collections.abc import Iterator
23
from functools import partial
3-
from typing import Callable, Iterator
4+
from typing import Callable
45

56
class MatplotlibDeprecationWarning(DeprecationWarning): ...
67

stubs/matplotlib/_mathtext.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class DejaVuSansFonts(DejaVuFonts): ...
6464

6565
class StixFonts(UnicodeFonts):
6666
def __init__(self, *args, **kwargs) -> None: ...
67-
@functools.lru_cache()
67+
@functools.lru_cache
6868
def get_sized_alternatives_for_symbol(self, fontname, sym) -> list[tuple]: ...
6969

7070
class StixSansFonts(StixFonts): ...

stubs/matplotlib/_pylab_helpers.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, List, OrderedDict
1+
from collections import OrderedDict
22

33
from .backend_bases import FigureManagerBase
44
from .figure import Figure

stubs/matplotlib/_text_helpers.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Generator
1+
from collections.abc import Generator
22

33
LayoutItem = ...
44

stubs/matplotlib/_tight_layout.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Sequence
1+
from collections.abc import Sequence
22

33
from .axes import Axes, SubplotBase
44
from .backend_bases import RendererBase

stubs/matplotlib/afm.pyi

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# COMPLETE
22

3-
from typing import BinaryIO, List, Literal, NamedTuple, Optional, Tuple, Union, overload
3+
from typing import BinaryIO, Literal, NamedTuple, overload
44

55
class CharMetrics(NamedTuple):
66
width: float
77
name: str
8-
bbox: List[int]
8+
bbox: list[int]
99

1010
class CompositePart(NamedTuple):
1111
name: str
@@ -20,11 +20,11 @@ class AFM:
2020
def family_name(self) -> str: ...
2121
def get_angle(self) -> float: ...
2222
@overload
23-
def get_bbox_char(self, c: str, isord: Literal[False] = ...) -> List[int]: ...
23+
def get_bbox_char(self, c: str, isord: Literal[False] = ...) -> list[int]: ...
2424
@overload
25-
def get_bbox_char(self, c: int, isord: Literal[True] = ...) -> List[int]: ...
25+
def get_bbox_char(self, c: int, isord: Literal[True] = ...) -> list[int]: ...
2626
@overload
27-
def get_bbox_char(self, c: Union[str, int], isord: bool = ...) -> List[int]: ...
27+
def get_bbox_char(self, c: str | int, isord: bool = ...) -> list[int]: ...
2828
def get_capheight(self) -> float: ...
2929
def get_familyname(self) -> str: ...
3030
def get_fontname(self) -> str: ...
@@ -34,27 +34,27 @@ class AFM:
3434
@overload
3535
def get_height_char(self, c: int, isord: Literal[True] = ...) -> int: ...
3636
@overload
37-
def get_height_char(self, c: Union[str, int], isord: bool = ...) -> int: ...
37+
def get_height_char(self, c: str | int, isord: bool = ...) -> int: ...
3838
def get_horizontal_stem_width(self) -> float: ...
39-
def get_kern_dist(self, c1: Union[str, int], c2: Union[str, int]) -> float: ...
39+
def get_kern_dist(self, c1: str | int, c2: str | int) -> float: ...
4040
def get_kern_dist_from_name(self, name1: str, name2: str) -> float: ...
4141
@overload
4242
def get_name_char(self, c: str, isord: Literal[False] = ...) -> str: ...
4343
@overload
4444
def get_name_char(self, c: int, isord: Literal[True] = ...) -> str: ...
4545
@overload
46-
def get_name_char(self, c: Union[str, int], isord: bool = ...) -> str: ...
47-
def get_str_bbox(self, s: Union[str, bytes]) -> Tuple[float, float, float, float, float]: ...
48-
def get_str_bbox_and_descent(self, s: Union[str, bytes]) -> Tuple[float, float, float, float, float]: ...
46+
def get_name_char(self, c: str | int, isord: bool = ...) -> str: ...
47+
def get_str_bbox(self, s: str | bytes) -> tuple[float, float, float, float, float]: ...
48+
def get_str_bbox_and_descent(self, s: str | bytes) -> tuple[float, float, float, float, float]: ...
4949
def get_underline_thickness(self) -> float: ...
50-
def get_vertical_stem_width(self) -> Optional[float]: ...
50+
def get_vertical_stem_width(self) -> float | None: ...
5151
def get_weight(self) -> str: ...
5252
@overload
5353
def get_width_char(self, c: str, isord: Literal[False] = ...) -> float: ...
5454
@overload
5555
def get_width_char(self, c: int, isord: Literal[True] = ...) -> float: ...
5656
@overload
57-
def get_width_char(self, c: Union[str, int], isord: bool = ...) -> float: ...
57+
def get_width_char(self, c: str | int, isord: bool = ...) -> float: ...
5858
def get_width_from_char_name(self, name: str) -> float: ...
5959
def get_xheight(self) -> float: ...
60-
def string_width_height(self, s: str) -> Tuple[float, float]: ...
60+
def string_width_height(self, s: str) -> tuple[float, float]: ...

stubs/matplotlib/animation.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import abc
22
import contextlib
3+
from collections.abc import Generator, Iterable, Iterator
34
from itertools import count
4-
from typing import Callable, Generator, Iterable, Iterator, List
5+
from typing import Callable
56

67
from matplotlib.backend_bases import NonGuiException
78

0 commit comments

Comments
 (0)