Skip to content

Commit

Permalink
Apply flake8-pyi-autofixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam committed Jan 28, 2025
1 parent 735c2f9 commit 258163f
Show file tree
Hide file tree
Showing 317 changed files with 859 additions and 1,170 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ jobs:
uses: actions/checkout@v2

- name: Run Ruff Linter
uses: astral-sh/ruff-action@v1

- name: Run Ruff Formatter
uses: astral-sh/ruff-action@v1
uses: astral-sh/ruff-action@v3
with:
args: "format --check"
version: "0.9.*"
- run: ruff format --check
26 changes: 26 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,34 @@ line-length = 130
target-version = "py39"

[tool.ruff.lint]
# TODO: Use extend-select instead to get base E and F rules that don't conflict with the formatter
select = [
"FA", # flake8-future-annotations
"I", # isort
"PYI", # flake8-pyi
]
ignore = [
###
# Rules we don't want or don't agree with
###
# Typeshed doesn't want complex or non-literal defaults for maintenance and testing reasons.
# This doesn't affect us, let's have more complete stubs.
"PYI011",
"PYI014",

# TODO: Handle in its own PR
"PYI021", # https://github.com/microsoft/python-type-stubs/pull/343

# TODO: Investigate and fix or configure
"PYI001",
"PYI002",
"PYI017",
"PYI019", # Request for more autofixes: https://github.com/astral-sh/ruff/issues/14183#issuecomment-2481832123
"PYI024",
"PYI048",
"PYI051", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
"PYI052",
"PYI061", # Request for more autofixes: https://github.com/astral-sh/ruff/issues/14537#issuecomment-2620034765
]

[tool.ruff.lint.isort]
Expand Down
2 changes: 1 addition & 1 deletion stubs/matplotlib/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ def is_interactive() -> bool: ...
default_test_modules: list[str] = ...

def test(verbosity=..., coverage=..., **kwargs):
int: ...
...
1 change: 0 additions & 1 deletion stubs/matplotlib/_layoutgrid.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class LayoutGrid:
width_ratios: None | list[float] = None,
height_ratios: None | list[float] = None,
) -> None: ...
def __repr__(self) -> str: ...
def reset_margins(self) -> None: ...
def add_constraints(self) -> None: ...
def hard_constraints(self) -> None: ...
Expand Down
4 changes: 0 additions & 4 deletions stubs/matplotlib/_mathtext.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ class DejaVuSansFontConstants(FontConstantsBase): ...

class Node:
def __init__(self) -> None: ...
def __repr__(self) -> str: ...
def get_kerning(self, next) -> float: ...
def shrink(self) -> None: ...
def render(self, x: float, y: float) -> None: ...
Expand All @@ -129,7 +128,6 @@ class Hbox(Box):

class Char(Node):
def __init__(self, c, state) -> None: ...
def __repr__(self) -> str: ...
def is_slanted(self) -> bool: ...
def get_kerning(self, next) -> float: ...
def render(self, x: float, y: float) -> None: ...
Expand All @@ -141,7 +139,6 @@ class Accent(Char):

class List(Box):
def __init__(self, elements) -> None: ...
def __repr__(self) -> str: ...
def shrink(self) -> None: ...

class Hlist(List):
Expand Down Expand Up @@ -179,7 +176,6 @@ class Kern(Node):
height: float = ...
depth: float = ...
def __init__(self, width: float) -> None: ...
def __repr__(self) -> str: ...
def shrink(self) -> None: ...

class AutoHeightChar(Hlist):
Expand Down
9 changes: 5 additions & 4 deletions stubs/matplotlib/_typing.pyi
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import decimal
import io
import typing_extensions

import numpy.typing
import pandas as pd

Decimal = decimal.Decimal
PythonScalar = str | int | float | bool
PythonScalar: typing_extensions.TypeAlias = str | int | float | bool

ArrayLike = numpy.typing.ArrayLike
FileLike = io.IOBase
PathLike = str

PandasScalar = pd.Period | pd.Timestamp | pd.Timedelta | pd.Interval
Scalar = PythonScalar | PandasScalar
PandasScalar: typing_extensions.TypeAlias = pd.Period | pd.Timestamp | pd.Timedelta | pd.Interval
Scalar: typing_extensions.TypeAlias = PythonScalar | PandasScalar

Color = tuple[float, float, float] | str
Color: typing_extensions.TypeAlias = tuple[float, float, float] | str

__all__ = [
"ArrayLike",
Expand Down
2 changes: 1 addition & 1 deletion stubs/matplotlib/animation.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class MovieWriterRegistry:
def __init__(self) -> None: ...
def register(self, name: str) -> Callable: ...
def is_available(self, name: str) -> bool: ...
def __iter__(self) -> Generator: ...
def __iter__(self) -> Iterator: ...
def list(self) -> list[MovieWriter]: ...
def __getitem__(self, name) -> MovieWriter: ...

Expand Down
2 changes: 1 addition & 1 deletion stubs/matplotlib/artist.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def allow_rasterization(
) -> Callable: ...

class _Unset:
def __repr__(self) -> str: ...
...

class Artist:
zorder: int = ...
Expand Down
2 changes: 0 additions & 2 deletions stubs/matplotlib/axes/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class _axis_method_wrapper:
class _AxesBase(Artist):
name: str = ...

def __str__(self) -> str: ...
def __init__(
self,
fig: Figure,
Expand All @@ -43,7 +42,6 @@ class _AxesBase(Artist):
) -> None: ...
def __getstate__(self) -> dict[str, Any]: ...
def __setstate__(self, state) -> None: ...
def __repr__(self) -> str: ...
def get_window_extent(self, renderer=..., *args, **kwargs) -> TransformedBbox: ...
def set_figure(self, fig: Figure) -> None: ...
@property
Expand Down
1 change: 0 additions & 1 deletion stubs/matplotlib/axis.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ class Axis(Artist):

OFFSETTEXTPAD: int = ...

def __str__(self) -> str: ...
def __init__(self, axes: Axes, pickradius: float = ...) -> None: ...
@property
def isDefault_majloc(self) -> bool: ...
Expand Down
2 changes: 0 additions & 2 deletions stubs/matplotlib/backend_bases.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ class MouseEvent(LocationEvent):
dblclick: bool = ...,
guiEvent=...,
) -> None: ...
def __str__(self) -> str: ...

class PickEvent(Event):
mouseevent: MouseEvent
Expand Down Expand Up @@ -343,7 +342,6 @@ class _Mode(str, Enum):
NONE: _Mode
PAN: _Mode
ZOOM: _Mode
def __str__(self) -> str: ...

class NavigationToolbar2:
toolitems = ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/matplotlib/backends/backend_agg.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RendererAgg(RendererBase):
def get_text_width_height_descent(self, s: str, prop: FontProperties, ismath: bool) -> tuple[float, float, float]: ...
def draw_tex(self, gc: GraphicsContextBase, x, y, s: str, prop: FontProperties, angle, *, mtext=...) -> None: ...
def get_canvas_width_height(self) -> tuple[float, float]: ...
def points_to_pixels(self, points: int | float) -> float: ...
def points_to_pixels(self, points: float) -> float: ...
def buffer_rgba(self) -> memoryview: ...
def tostring_argb(self) -> bytes: ...
def tostring_rgb(self) -> bytes: ...
Expand Down
8 changes: 4 additions & 4 deletions stubs/matplotlib/backends/backend_gtk3.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class __getattr__:

class FigureCanvasGTK3(Gtk.DrawingArea, FigureCanvasBase):
required_interactive_framework: str = ...
_timer_cls: Type[TimerGTK3] = TimerGTK3
_timer_cls: Type[TimerGTK3] = ...
manager_class: classproperty = ...
event_mask: int = ...

Expand Down Expand Up @@ -66,10 +66,10 @@ class ToolCopyToClipboardGTK3(backend_tools.ToolCopyToClipboardBase):

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

Toolbar: Type[ToolbarGTK3] = ToolbarGTK3
Toolbar: Type[ToolbarGTK3] = ...

class FigureManagerGTK3(_FigureManagerGTK): ...

class _BackendGTK3(_BackendGTK):
FigureCanvas: Type[FigureCanvasGTK3] = FigureCanvasGTK3
FigureManager: Type[FigureManagerGTK3] = FigureManagerGTK3
FigureCanvas: Type[FigureCanvasGTK3] = ...
FigureManager: Type[FigureManagerGTK3] = ...
16 changes: 6 additions & 10 deletions stubs/matplotlib/backends/backend_pdf.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ from enum import Enum
from functools import total_ordering
from io import BytesIO
from typing import Any, Callable, Optional, Set
from typing_extensions import Self

import numpy as np
from matplotlib._enums import CapStyle, JoinStyle
Expand All @@ -19,15 +20,12 @@ def pdfRepr(obj) -> bytes: ...

class Reference:
def __init__(self, id: int) -> None: ...
def __repr__(self) -> str: ...
def pdfRepr(self) -> bytes: ...
def write(self, contentsy, file: "PdfFile") -> None: ...
def write(self, contentsy, file: PdfFile) -> None: ...

@total_ordering
class Name:
def __init__(self, name: bytes | Name | str) -> None: ...
def __repr__(self) -> str: ...
def __str__(self) -> str: ...
def __eq__(self, other) -> bool: ...
def __lt__(self, other) -> bool: ...
def __hash__(self) -> int: ...
Expand All @@ -37,7 +35,6 @@ class Name:

class Operator:
def __init__(self, op) -> None: ...
def __repr__(self) -> str: ...
def pdfRepr(self) -> bytes: ...

class Verbatim:
Expand Down Expand Up @@ -154,7 +151,7 @@ class RendererPdf(_backend_pdf_ps.RendererPDFPSBase):
def finalize(self) -> None: ...
def check_gc(
self,
gc: "GraphicsContextPdf",
gc: GraphicsContextPdf,
fillcolor: None | tuple[float, float, float, float] = ...,
) -> None: ...
def get_image_magnification(self) -> float: ...
Expand Down Expand Up @@ -212,7 +209,6 @@ class RendererPdf(_backend_pdf_ps.RendererPDFPSBase):

class GraphicsContextPdf(GraphicsContextBase):
def __init__(self, file: PdfFile) -> None: ...
def __repr__(self) -> str: ...
def stroke(self) -> bool: ...
def fill(self, *args) -> bool: ...
def paint(
Expand All @@ -222,7 +218,7 @@ class GraphicsContextPdf(GraphicsContextBase):
joinstyles: dict[str, int] = ...
def capstyle_cmd(self, style: CapStyle) -> list[int | Op]: ...
def joinstyle_cmd(self, style: JoinStyle) -> list[int | Op]: ...
def linewidth_cmd(self, width: int | float) -> list[float | Op]: ...
def linewidth_cmd(self, width: float) -> list[float | Op]: ...
def dash_cmd(self, dashes) -> list: ...
def alpha_cmd(self, alpha: float, forced: bool, effective_alphas: tuple[float, float]) -> list[Name | Op]: ...
def hatch_cmd(self, hatch: None, hatch_color: tuple[float, float, float, float]) -> list[Name | Op | float]: ...
Expand All @@ -238,13 +234,13 @@ class GraphicsContextPdf(GraphicsContextBase):
def pop(self) -> list[Op]: ...
def clip_cmd(self, cliprect, clippath) -> list[Op]: ...
commands: tuple = ...
def delta(self, other: "GraphicsContextPdf") -> list[Op | Name | float]: ...
def delta(self, other: GraphicsContextPdf) -> list[Op | Name | float]: ...
def copy_properties(self, other: GraphicsContextPdf) -> None: ...
def finalize(self) -> list[Op]: ...

class PdfPages:
def __init__(self, filename: str, keep_empty: bool = ..., metadata: dict[str, Any] = ...) -> None: ...
def __enter__(self) -> PdfPages: ...
def __enter__(self) -> Self: ...
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
def close(self) -> None: ...
def infodict(self) -> dict[str, Any]: ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/matplotlib/backends/backend_pgf.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Callable
from typing_extensions import Self

import numpy as np
from matplotlib import _api
Expand Down Expand Up @@ -27,7 +28,6 @@ def make_pdf_to_png_converter() -> Callable: ...

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

class LatexManager:
def __init__(self) -> None: ...
Expand Down Expand Up @@ -90,7 +90,7 @@ class _BackendPgf(_Backend):

class PdfPages:
def __init__(self, filename: str | PathLike, *, keep_empty: bool = True, metadata: dict[str, Any] = ...) -> None: ...
def __enter__(self) -> PdfPages: ...
def __enter__(self) -> Self: ...
def __exit__(self, exc_type, exc_val, exc_tb) -> None: ...
def close(self) -> None: ...
def savefig(self, figure: Figure | int = ..., **kwargs) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/matplotlib/backends/backend_qt.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class TimerQT(TimerBase):

class FigureCanvasQT(QtWidgets.QWidget, FigureCanvasBase):
required_interactive_framework: str = ...
_timer_cls: Type[TimerQT] = TimerQT
_timer_cls: Type[TimerQT] = ...
manager_class: classproperty = ...
buttond: dict[str, MouseButton] = ...

Expand Down
2 changes: 1 addition & 1 deletion stubs/matplotlib/backends/backend_tkagg.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ class FigureCanvasTkAgg(FigureCanvasAgg, FigureCanvasTk):
def blit(self, bbox: Bbox = ...) -> None: ...

class _BackendTkAgg(_BackendTk):
FigureCanvas: Type[FigureCanvasAgg] = FigureCanvasTkAgg
FigureCanvas: Type[FigureCanvasAgg] = ...
5 changes: 2 additions & 3 deletions stubs/matplotlib/cbook/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class CallbackRegistry:

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

def strip_math(s: str) -> str: ...
def is_writable_file_like(obj) -> bool: ...
Expand Down Expand Up @@ -65,7 +64,7 @@ class Stack:
def remove(self, o) -> None: ...

def report_memory(i=...):
int: ...
...

def safe_masked_invalid(x, copy=...) -> np.ndarray: ...
def print_cycles(objects, outstream=..., show_progress: bool = ...) -> None: ...
Expand All @@ -77,7 +76,7 @@ class Grouper:
def join(self, a, *args) -> bool: ...
def joined(self, a, b) -> bool: ...
def remove(self, a) -> None: ...
def __iter__(self) -> Generator: ...
def __iter__(self) -> Iterator: ...
def get_siblings(self, a) -> list: ...

class GrouperView:
Expand Down
1 change: 0 additions & 1 deletion stubs/matplotlib/cm.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class ColormapRegistry(Mapping):
def __getitem__(self, item: str): ...
def __iter__(self): ...
def __len__(self) -> int: ...
def __str__(self) -> str: ...
def __call__(self): ...
def register(self, cmap: Colormap, *, name: str = ..., force: bool = ...) -> None: ...
def unregister(self, name: str) -> None: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/matplotlib/colorbar.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class Colorbar:
def remove(self) -> None: ...
def drag_pan(self, button, key, x, y) -> None: ...

ColorbarBase: Type[Colorbar] = Colorbar
ColorbarBase: Type[Colorbar] = ...

def make_axes(
parents: Axes | list[Axes],
Expand Down
3 changes: 1 addition & 2 deletions stubs/matplotlib/colors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class ColorSequenceRegistry(Mapping):
def __getitem__(self, item) -> list[Color]: ...
def __iter__(self) -> Iterator[Color]: ...
def __len__(self) -> int: ...
def __str__(self) -> str: ...
def register(self, name: str, color_list: list[Color]) -> None: ...
def unregister(self, name) -> None: ...

Expand Down Expand Up @@ -53,7 +52,7 @@ class Colormap:
def __init__(self, name: str, N: int = 256) -> None: ...
def __call__(
self,
X: float | int | np.ndarray | Scalar,
X: float | np.ndarray | Scalar,
alpha: float | ArrayLike | None = None,
bytes: bool = False,
) -> tuple: ...
Expand Down
4 changes: 2 additions & 2 deletions stubs/matplotlib/container.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Literal, Type
from typing_extensions import Self

from matplotlib.artist import Artist

Expand All @@ -8,8 +9,7 @@ from .lines import Line2D
from .patches import Rectangle

class Container(tuple):
def __repr__(self) -> str: ...
def __new__(cls: Type[Container], *args, **kwargs) -> Container: ...
def __new__(cls, *args, **kwargs) -> Self: ...
def __init__(self, kl: list[Rectangle], label: str = ...) -> None: ...
def remove(self) -> None: ...
def get_children(self) -> list[Rectangle]: ...
Expand Down
Loading

0 comments on commit 258163f

Please sign in to comment.