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 Nov 10, 2024
1 parent ca8036b commit 4f2c818
Show file tree
Hide file tree
Showing 305 changed files with 736 additions and 1,054 deletions.
26 changes: 25 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,33 @@ 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: Investigate and fix or configure
"PYI001",
"PYI002",
"PYI017",
"PYI019", # Request for autofix: https://github.com/astral-sh/ruff/issues/14183
"PYI021", # Request for autofix: https://github.com/astral-sh/ruff/issues/14123
"PYI024",
"PYI034", # Request for autofix: https://github.com/astral-sh/ruff/issues/14184
"PYI041", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
"PYI048",
"PYI051", # Request for autofix: https://github.com/astral-sh/ruff/issues/14185
"PYI052",
]

[tool.ruff.lint.isort]
Expand Down Expand Up @@ -84,7 +109,6 @@ extra-standard-library = [

[tool.pyright]
exclude = ["build", ".git"]
stubPath = "./stubs"
# Target oldest supported Python version
pythonversion = "3.9"
typeCheckingMode = "standard"
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
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] = ...
11 changes: 3 additions & 8 deletions stubs/matplotlib/backends/backend_pdf.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,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 +34,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 +150,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 +208,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 @@ -238,7 +233,7 @@ 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]: ...

Expand Down
1 change: 0 additions & 1 deletion stubs/matplotlib/backends/backend_pgf.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,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
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
1 change: 0 additions & 1 deletion 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
1 change: 0 additions & 1 deletion stubs/matplotlib/container.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ from .lines import Line2D
from .patches import Rectangle

class Container(tuple):
def __repr__(self) -> str: ...
def __new__(cls: Type[Container], *args, **kwargs) -> Container: ...
def __init__(self, kl: list[Rectangle], label: str = ...) -> None: ...
def remove(self) -> None: ...
Expand Down
1 change: 0 additions & 1 deletion stubs/matplotlib/dviread.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class DviFont:
def __init__(self, scale: float, tfm: Tfm, texname: bytes, vf: Vf) -> None: ...
def __eq__(self, other) -> bool: ...
def __ne__(self, other) -> bool: ...
def __repr__(self) -> str: ...

class Vf(Dvi):
def __init__(self, filename: str | PathLike) -> None: ...
Expand Down
1 change: 0 additions & 1 deletion stubs/matplotlib/figure.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ class FigureBase(Artist):

class Figure(FigureBase):
callbacks = ...
def __str__(self) -> str: ...
def __repr__(self): ...
def __init__(
self,
Expand Down
5 changes: 2 additions & 3 deletions stubs/matplotlib/font_manager.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,7 @@ class FontProperties:
math_fontfamily: Literal["dejavusans", "dejavuserif", "cm", "stix", "stixsans", "custom"] = ...,
) -> None: ...
def __hash__(self) -> int: ...
def __eq__(self, other: "FontProperties") -> bool: ...
def __str__(self) -> str: ...
def __eq__(self, other: FontProperties) -> bool: ...
def get_family(self) -> list[str]: ...
def get_name(self) -> str: ...
def get_style(self) -> str: ...
Expand Down Expand Up @@ -152,7 +151,7 @@ class FontProperties:
self,
fontfamily: Literal["dejavusans", "dejavuserif", "cm", "stix", "stixsans", "custom"],
) -> None: ...
def copy(self) -> "FontProperties": ...
def copy(self) -> FontProperties: ...
set_name = ...
get_slant = ...
set_slant = ...
Expand Down
2 changes: 0 additions & 2 deletions stubs/matplotlib/gridspec.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class GridSpecBase:
height_ratios: ArrayLike = ...,
width_ratios: ArrayLike = ...,
) -> None: ...
def __repr__(self) -> str: ...

nrows = ...
ncols = ...
Expand Down Expand Up @@ -76,7 +75,6 @@ class SubplotSpec:
num1: int,
num2: int = ...,
) -> None: ...
def __repr__(self) -> str: ...
@property
def num2(self): ...
@num2.setter
Expand Down
1 change: 0 additions & 1 deletion stubs/matplotlib/image.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class _ImageBase(Artist, ScalarMappable):
interpolation_stage=...,
**kwargs,
) -> None: ...
def __str__(self) -> str: ...
def __getstate__(self): ...
def get_size(self): ...
def set_alpha(self, alpha: float | ArrayLike | None) -> None: ...
Expand Down
1 change: 0 additions & 1 deletion stubs/matplotlib/legend.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class DraggableLegend(DraggableOffsetBox):
class Legend(Artist):
codes = ...
zorder = ...
def __str__(self) -> str: ...
def __init__(
self,
parent: Axes | Figure,
Expand Down
Loading

0 comments on commit 4f2c818

Please sign in to comment.