Skip to content

Commit 4f2c818

Browse files
committed
Apply flake8-pyi-autofixes
1 parent ca8036b commit 4f2c818

File tree

305 files changed

+736
-1054
lines changed

Some content is hidden

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

305 files changed

+736
-1054
lines changed

pyproject.toml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,33 @@ line-length = 130
2727
target-version = "py39"
2828

2929
[tool.ruff.lint]
30+
# TODO: Use extend-select instead to get base E and F rules that don't conflict with the formatter
3031
select = [
32+
"FA", # flake8-future-annotations
3133
"I", # isort
34+
"PYI", # flake8-pyi
35+
]
36+
ignore = [
37+
###
38+
# Rules we don't want or don't agree with
39+
###
40+
# Typeshed doesn't want complex or non-literal defaults for maintenance and testing reasons.
41+
# This doesn't affect us, let's have more complete stubs.
42+
"PYI011",
43+
"PYI014",
44+
45+
# TODO: Investigate and fix or configure
46+
"PYI001",
47+
"PYI002",
48+
"PYI017",
49+
"PYI019", # Request for autofix: https://github.com/astral-sh/ruff/issues/14183
50+
"PYI021", # Request for autofix: https://github.com/astral-sh/ruff/issues/14123
51+
"PYI024",
52+
"PYI034", # Request for autofix: https://github.com/astral-sh/ruff/issues/14184
53+
"PYI041", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
54+
"PYI048",
55+
"PYI051", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
56+
"PYI052",
3257
]
3358

3459
[tool.ruff.lint.isort]
@@ -84,7 +109,6 @@ extra-standard-library = [
84109

85110
[tool.pyright]
86111
exclude = ["build", ".git"]
87-
stubPath = "./stubs"
88112
# Target oldest supported Python version
89113
pythonversion = "3.9"
90114
typeCheckingMode = "standard"

stubs/matplotlib/__init__.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ def is_interactive() -> bool: ...
4848
default_test_modules: list[str] = ...
4949

5050
def test(verbosity=..., coverage=..., **kwargs):
51-
int: ...
51+
...

stubs/matplotlib/_layoutgrid.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class LayoutGrid:
1818
width_ratios: None | list[float] = None,
1919
height_ratios: None | list[float] = None,
2020
) -> None: ...
21-
def __repr__(self) -> str: ...
2221
def reset_margins(self) -> None: ...
2322
def add_constraints(self) -> None: ...
2423
def hard_constraints(self) -> None: ...

stubs/matplotlib/_mathtext.pyi

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ class DejaVuSansFontConstants(FontConstantsBase): ...
111111

112112
class Node:
113113
def __init__(self) -> None: ...
114-
def __repr__(self) -> str: ...
115114
def get_kerning(self, next) -> float: ...
116115
def shrink(self) -> None: ...
117116
def render(self, x: float, y: float) -> None: ...
@@ -129,7 +128,6 @@ class Hbox(Box):
129128

130129
class Char(Node):
131130
def __init__(self, c, state) -> None: ...
132-
def __repr__(self) -> str: ...
133131
def is_slanted(self) -> bool: ...
134132
def get_kerning(self, next) -> float: ...
135133
def render(self, x: float, y: float) -> None: ...
@@ -141,7 +139,6 @@ class Accent(Char):
141139

142140
class List(Box):
143141
def __init__(self, elements) -> None: ...
144-
def __repr__(self) -> str: ...
145142
def shrink(self) -> None: ...
146143

147144
class Hlist(List):
@@ -179,7 +176,6 @@ class Kern(Node):
179176
height: float = ...
180177
depth: float = ...
181178
def __init__(self, width: float) -> None: ...
182-
def __repr__(self) -> str: ...
183179
def shrink(self) -> None: ...
184180

185181
class AutoHeightChar(Hlist):

stubs/matplotlib/_typing.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import decimal
22
import io
3+
import typing_extensions
34

45
import numpy.typing
56
import pandas as pd
67

78
Decimal = decimal.Decimal
8-
PythonScalar = str | int | float | bool
9+
PythonScalar: typing_extensions.TypeAlias = str | int | float | bool
910

1011
ArrayLike = numpy.typing.ArrayLike
1112
FileLike = io.IOBase
1213
PathLike = str
1314

14-
PandasScalar = pd.Period | pd.Timestamp | pd.Timedelta | pd.Interval
15-
Scalar = PythonScalar | PandasScalar
15+
PandasScalar: typing_extensions.TypeAlias = pd.Period | pd.Timestamp | pd.Timedelta | pd.Interval
16+
Scalar: typing_extensions.TypeAlias = PythonScalar | PandasScalar
1617

17-
Color = tuple[float, float, float] | str
18+
Color: typing_extensions.TypeAlias = tuple[float, float, float] | str
1819

1920
__all__ = [
2021
"ArrayLike",

stubs/matplotlib/animation.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MovieWriterRegistry:
1515
def __init__(self) -> None: ...
1616
def register(self, name: str) -> Callable: ...
1717
def is_available(self, name: str) -> bool: ...
18-
def __iter__(self) -> Generator: ...
18+
def __iter__(self) -> Iterator: ...
1919
def list(self) -> list[MovieWriter]: ...
2020
def __getitem__(self, name) -> MovieWriter: ...
2121

stubs/matplotlib/artist.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def allow_rasterization(
1414
) -> Callable: ...
1515

1616
class _Unset:
17-
def __repr__(self) -> str: ...
17+
...
1818

1919
class Artist:
2020
zorder: int = ...

stubs/matplotlib/axes/_base.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class _axis_method_wrapper:
2525
class _AxesBase(Artist):
2626
name: str = ...
2727

28-
def __str__(self) -> str: ...
2928
def __init__(
3029
self,
3130
fig: Figure,
@@ -43,7 +42,6 @@ class _AxesBase(Artist):
4342
) -> None: ...
4443
def __getstate__(self) -> dict[str, Any]: ...
4544
def __setstate__(self, state) -> None: ...
46-
def __repr__(self) -> str: ...
4745
def get_window_extent(self, renderer=..., *args, **kwargs) -> TransformedBbox: ...
4846
def set_figure(self, fig: Figure) -> None: ...
4947
@property

stubs/matplotlib/axis.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ class Axis(Artist):
109109

110110
OFFSETTEXTPAD: int = ...
111111

112-
def __str__(self) -> str: ...
113112
def __init__(self, axes: Axes, pickradius: float = ...) -> None: ...
114113
@property
115114
def isDefault_majloc(self) -> bool: ...

stubs/matplotlib/backend_bases.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,6 @@ class MouseEvent(LocationEvent):
220220
dblclick: bool = ...,
221221
guiEvent=...,
222222
) -> None: ...
223-
def __str__(self) -> str: ...
224223

225224
class PickEvent(Event):
226225
mouseevent: MouseEvent
@@ -343,7 +342,6 @@ class _Mode(str, Enum):
343342
NONE: _Mode
344343
PAN: _Mode
345344
ZOOM: _Mode
346-
def __str__(self) -> str: ...
347345

348346
class NavigationToolbar2:
349347
toolitems = ...

stubs/matplotlib/backends/backend_gtk3.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class __getattr__:
1717

1818
class FigureCanvasGTK3(Gtk.DrawingArea, FigureCanvasBase):
1919
required_interactive_framework: str = ...
20-
_timer_cls: Type[TimerGTK3] = TimerGTK3
20+
_timer_cls: Type[TimerGTK3] = ...
2121
manager_class: classproperty = ...
2222
event_mask: int = ...
2323

@@ -66,10 +66,10 @@ class ToolCopyToClipboardGTK3(backend_tools.ToolCopyToClipboardBase):
6666

6767
def error_msg_gtk(msg, parent=...) -> None: ...
6868

69-
Toolbar: Type[ToolbarGTK3] = ToolbarGTK3
69+
Toolbar: Type[ToolbarGTK3] = ...
7070

7171
class FigureManagerGTK3(_FigureManagerGTK): ...
7272

7373
class _BackendGTK3(_BackendGTK):
74-
FigureCanvas: Type[FigureCanvasGTK3] = FigureCanvasGTK3
75-
FigureManager: Type[FigureManagerGTK3] = FigureManagerGTK3
74+
FigureCanvas: Type[FigureCanvasGTK3] = ...
75+
FigureManager: Type[FigureManagerGTK3] = ...

stubs/matplotlib/backends/backend_pdf.pyi

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,12 @@ def pdfRepr(obj) -> bytes: ...
1919

2020
class Reference:
2121
def __init__(self, id: int) -> None: ...
22-
def __repr__(self) -> str: ...
2322
def pdfRepr(self) -> bytes: ...
24-
def write(self, contentsy, file: "PdfFile") -> None: ...
23+
def write(self, contentsy, file: PdfFile) -> None: ...
2524

2625
@total_ordering
2726
class Name:
2827
def __init__(self, name: bytes | Name | str) -> None: ...
29-
def __repr__(self) -> str: ...
30-
def __str__(self) -> str: ...
3128
def __eq__(self, other) -> bool: ...
3229
def __lt__(self, other) -> bool: ...
3330
def __hash__(self) -> int: ...
@@ -37,7 +34,6 @@ class Name:
3734

3835
class Operator:
3936
def __init__(self, op) -> None: ...
40-
def __repr__(self) -> str: ...
4137
def pdfRepr(self) -> bytes: ...
4238

4339
class Verbatim:
@@ -154,7 +150,7 @@ class RendererPdf(_backend_pdf_ps.RendererPDFPSBase):
154150
def finalize(self) -> None: ...
155151
def check_gc(
156152
self,
157-
gc: "GraphicsContextPdf",
153+
gc: GraphicsContextPdf,
158154
fillcolor: None | tuple[float, float, float, float] = ...,
159155
) -> None: ...
160156
def get_image_magnification(self) -> float: ...
@@ -212,7 +208,6 @@ class RendererPdf(_backend_pdf_ps.RendererPDFPSBase):
212208

213209
class GraphicsContextPdf(GraphicsContextBase):
214210
def __init__(self, file: PdfFile) -> None: ...
215-
def __repr__(self) -> str: ...
216211
def stroke(self) -> bool: ...
217212
def fill(self, *args) -> bool: ...
218213
def paint(
@@ -238,7 +233,7 @@ class GraphicsContextPdf(GraphicsContextBase):
238233
def pop(self) -> list[Op]: ...
239234
def clip_cmd(self, cliprect, clippath) -> list[Op]: ...
240235
commands: tuple = ...
241-
def delta(self, other: "GraphicsContextPdf") -> list[Op | Name | float]: ...
236+
def delta(self, other: GraphicsContextPdf) -> list[Op | Name | float]: ...
242237
def copy_properties(self, other: GraphicsContextPdf) -> None: ...
243238
def finalize(self) -> list[Op]: ...
244239

stubs/matplotlib/backends/backend_pgf.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def make_pdf_to_png_converter() -> Callable: ...
2727

2828
class LatexError(Exception):
2929
def __init__(self, message, latex_output=...) -> None: ...
30-
def __str__(self) -> str: ...
3130

3231
class LatexManager:
3332
def __init__(self) -> None: ...

stubs/matplotlib/backends/backend_qt.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TimerQT(TimerBase):
2929

3030
class FigureCanvasQT(QtWidgets.QWidget, FigureCanvasBase):
3131
required_interactive_framework: str = ...
32-
_timer_cls: Type[TimerQT] = TimerQT
32+
_timer_cls: Type[TimerQT] = ...
3333
manager_class: classproperty = ...
3434
buttond: dict[str, MouseButton] = ...
3535

stubs/matplotlib/backends/backend_tkagg.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@ class FigureCanvasTkAgg(FigureCanvasAgg, FigureCanvasTk):
1010
def blit(self, bbox: Bbox = ...) -> None: ...
1111

1212
class _BackendTkAgg(_BackendTk):
13-
FigureCanvas: Type[FigureCanvasAgg] = FigureCanvasTkAgg
13+
FigureCanvas: Type[FigureCanvasAgg] = ...

stubs/matplotlib/cbook/__init__.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class CallbackRegistry:
2525

2626
class silent_list(list):
2727
def __init__(self, type, seq=...) -> None: ...
28-
def __repr__(self) -> str: ...
2928

3029
def strip_math(s: str) -> str: ...
3130
def is_writable_file_like(obj) -> bool: ...
@@ -65,7 +64,7 @@ class Stack:
6564
def remove(self, o) -> None: ...
6665

6766
def report_memory(i=...):
68-
int: ...
67+
...
6968

7069
def safe_masked_invalid(x, copy=...) -> np.ndarray: ...
7170
def print_cycles(objects, outstream=..., show_progress: bool = ...) -> None: ...
@@ -77,7 +76,7 @@ class Grouper:
7776
def join(self, a, *args) -> bool: ...
7877
def joined(self, a, b) -> bool: ...
7978
def remove(self, a) -> None: ...
80-
def __iter__(self) -> Generator: ...
79+
def __iter__(self) -> Iterator: ...
8180
def get_siblings(self, a) -> list: ...
8281

8382
class GrouperView:

stubs/matplotlib/cm.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class ColormapRegistry(Mapping):
1111
def __getitem__(self, item: str): ...
1212
def __iter__(self): ...
1313
def __len__(self) -> int: ...
14-
def __str__(self) -> str: ...
1514
def __call__(self): ...
1615
def register(self, cmap: Colormap, *, name: str = ..., force: bool = ...) -> None: ...
1716
def unregister(self, name: str) -> None: ...

stubs/matplotlib/colorbar.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class Colorbar:
8282
def remove(self) -> None: ...
8383
def drag_pan(self, button, key, x, y) -> None: ...
8484

85-
ColorbarBase: Type[Colorbar] = Colorbar
85+
ColorbarBase: Type[Colorbar] = ...
8686

8787
def make_axes(
8888
parents: Axes | list[Axes],

stubs/matplotlib/colors.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class ColorSequenceRegistry(Mapping):
2121
def __getitem__(self, item) -> list[Color]: ...
2222
def __iter__(self) -> Iterator[Color]: ...
2323
def __len__(self) -> int: ...
24-
def __str__(self) -> str: ...
2524
def register(self, name: str, color_list: list[Color]) -> None: ...
2625
def unregister(self, name) -> None: ...
2726

stubs/matplotlib/container.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ from .lines import Line2D
88
from .patches import Rectangle
99

1010
class Container(tuple):
11-
def __repr__(self) -> str: ...
1211
def __new__(cls: Type[Container], *args, **kwargs) -> Container: ...
1312
def __init__(self, kl: list[Rectangle], label: str = ...) -> None: ...
1413
def remove(self) -> None: ...

stubs/matplotlib/dviread.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class DviFont:
2929
def __init__(self, scale: float, tfm: Tfm, texname: bytes, vf: Vf) -> None: ...
3030
def __eq__(self, other) -> bool: ...
3131
def __ne__(self, other) -> bool: ...
32-
def __repr__(self) -> str: ...
3332

3433
class Vf(Dvi):
3534
def __init__(self, filename: str | PathLike) -> None: ...

stubs/matplotlib/figure.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ class FigureBase(Artist):
189189

190190
class Figure(FigureBase):
191191
callbacks = ...
192-
def __str__(self) -> str: ...
193192
def __repr__(self): ...
194193
def __init__(
195194
self,

stubs/matplotlib/font_manager.pyi

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ class FontProperties:
8585
math_fontfamily: Literal["dejavusans", "dejavuserif", "cm", "stix", "stixsans", "custom"] = ...,
8686
) -> None: ...
8787
def __hash__(self) -> int: ...
88-
def __eq__(self, other: "FontProperties") -> bool: ...
89-
def __str__(self) -> str: ...
88+
def __eq__(self, other: FontProperties) -> bool: ...
9089
def get_family(self) -> list[str]: ...
9190
def get_name(self) -> str: ...
9291
def get_style(self) -> str: ...
@@ -152,7 +151,7 @@ class FontProperties:
152151
self,
153152
fontfamily: Literal["dejavusans", "dejavuserif", "cm", "stix", "stixsans", "custom"],
154153
) -> None: ...
155-
def copy(self) -> "FontProperties": ...
154+
def copy(self) -> FontProperties: ...
156155
set_name = ...
157156
get_slant = ...
158157
set_slant = ...

stubs/matplotlib/gridspec.pyi

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ class GridSpecBase:
1212
height_ratios: ArrayLike = ...,
1313
width_ratios: ArrayLike = ...,
1414
) -> None: ...
15-
def __repr__(self) -> str: ...
1615

1716
nrows = ...
1817
ncols = ...
@@ -76,7 +75,6 @@ class SubplotSpec:
7675
num1: int,
7776
num2: int = ...,
7877
) -> None: ...
79-
def __repr__(self) -> str: ...
8078
@property
8179
def num2(self): ...
8280
@num2.setter

stubs/matplotlib/image.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class _ImageBase(Artist, ScalarMappable):
3434
interpolation_stage=...,
3535
**kwargs,
3636
) -> None: ...
37-
def __str__(self) -> str: ...
3837
def __getstate__(self): ...
3938
def get_size(self): ...
4039
def set_alpha(self, alpha: float | ArrayLike | None) -> None: ...

stubs/matplotlib/legend.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class DraggableLegend(DraggableOffsetBox):
1818
class Legend(Artist):
1919
codes = ...
2020
zorder = ...
21-
def __str__(self) -> str: ...
2221
def __init__(
2322
self,
2423
parent: Axes | Figure,

0 commit comments

Comments
 (0)