From 311509d9adabedbca3c0bf7b26d4d0b283ed75f8 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 7 Nov 2024 18:45:29 -0500 Subject: [PATCH] Fix all reportUndefinedVariable (#334) --- pyproject.toml | 1 - stubs/matplotlib/backends/_backend_gtk.pyi | 2 ++ stubs/matplotlib/font_manager.pyi | 1 + stubs/matplotlib/widgets.pyi | 6 +++++- stubs/networkx/algorithms/planarity.pyi | 3 ++- stubs/sklearn/linear_model/_stochastic_gradient.pyi | 1 + stubs/sympy-stubs/polys/domains/algebraicfield.pyi | 3 +++ stubs/sympy-stubs/polys/domains/complexfield.pyi | 2 ++ stubs/sympy-stubs/polys/domains/expressiondomain.pyi | 7 +++++-- stubs/sympy-stubs/polys/domains/expressionrawdomain.pyi | 3 +++ stubs/sympy-stubs/printing/lambdarepr.pyi | 3 +-- stubs/sympy-stubs/stats/rv_interface.pyi | 7 +++---- stubs/vispy/visuals/shaders/variable.pyi | 1 + 13 files changed, 29 insertions(+), 11 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index d2098b90..0609d090 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -112,7 +112,6 @@ reportUnsupportedDunderAll = "error" reportAssertTypeFailure = "none" # TODO reportAttributeAccessIssue = "none" # TODO reportGeneralTypeIssues = "none" # TODO -reportUndefinedVariable = "none" # TODO [tool.mypy] # Target oldest supported Python version diff --git a/stubs/matplotlib/backends/_backend_gtk.pyi b/stubs/matplotlib/backends/_backend_gtk.pyi index 88e1d171..dc76decc 100644 --- a/stubs/matplotlib/backends/_backend_gtk.pyi +++ b/stubs/matplotlib/backends/_backend_gtk.pyi @@ -1,3 +1,5 @@ +# PyGObject is not easily installable on Windows, let tests pass as-is +from gi.repository import Gtk # pyright: ignore[reportMissingImports] from matplotlib import backend_tools from matplotlib._typing import * from matplotlib.backend_bases import FigureCanvasBase, FigureManagerBase, NavigationToolbar2, TimerBase, _Backend diff --git a/stubs/matplotlib/font_manager.pyi b/stubs/matplotlib/font_manager.pyi index c28095b7..c3804ac3 100644 --- a/stubs/matplotlib/font_manager.pyi +++ b/stubs/matplotlib/font_manager.pyi @@ -1,4 +1,5 @@ import json +from dataclasses import dataclass from functools import lru_cache from pathlib import PosixPath from typing import Literal diff --git a/stubs/matplotlib/widgets.pyi b/stubs/matplotlib/widgets.pyi index 5eac14b0..58d91e6d 100644 --- a/stubs/matplotlib/widgets.pyi +++ b/stubs/matplotlib/widgets.pyi @@ -6,17 +6,21 @@ from typing import Any, Callable, Dict, List, Literal, Mapping, Optional, Sequen import matplotlib as mpl import numpy as np from matplotlib.axes._axes import Axes -from matplotlib.backend_bases import MouseButton +from matplotlib.backend_bases import DrawEvent, Event, FigureCanvasBase, KeyEvent, MouseButton, MouseEvent from matplotlib.figure import Figure from matplotlib.lines import Line2D from matplotlib.patches import Ellipse, Rectangle from matplotlib.transforms import Affine2D from numpy import float64, ndarray from numpy.typing import ArrayLike +from PIL.Image import Image from . import _api, _docstring, backend_tools, cbook, colors, ticker, transforms +from ._typing import Color +from .artist import Artist from .lines import Line2D from .patches import Circle, Ellipse, Polygon, Rectangle +from .text import Text from .transforms import Affine2D, TransformedPatchPath class LockDraw: diff --git a/stubs/networkx/algorithms/planarity.pyi b/stubs/networkx/algorithms/planarity.pyi index 9fffcaec..d104ac32 100644 --- a/stubs/networkx/algorithms/planarity.pyi +++ b/stubs/networkx/algorithms/planarity.pyi @@ -3,6 +3,7 @@ from typing import Mapping from numpy.typing import ArrayLike +from ..classes.digraph import DiGraph from ..classes.graph import Graph __all__ = ["check_planarity", "is_planar", "PlanarEmbedding"] @@ -43,7 +44,7 @@ class LRPlanarity: def sign(self, e): ... def sign_recursive(self, e): ... -class PlanarEmbedding(nx.DiGraph): +class PlanarEmbedding(DiGraph): def get_data(self) -> Mapping: ... def set_data(self, data: Mapping): ... def neighbors_cw_order(self, v): ... diff --git a/stubs/sklearn/linear_model/_stochastic_gradient.pyi b/stubs/sklearn/linear_model/_stochastic_gradient.pyi index 15da71b2..b3f3194c 100644 --- a/stubs/sklearn/linear_model/_stochastic_gradient.pyi +++ b/stubs/sklearn/linear_model/_stochastic_gradient.pyi @@ -22,6 +22,7 @@ from ._sgd_fast import ( Hinge as Hinge, Huber as Huber, Log as Log, + LossFunction, ModifiedHuber as ModifiedHuber, SquaredEpsilonInsensitive as SquaredEpsilonInsensitive, SquaredHinge as SquaredHinge, diff --git a/stubs/sympy-stubs/polys/domains/algebraicfield.pyi b/stubs/sympy-stubs/polys/domains/algebraicfield.pyi index 25c4f9d6..8390019e 100644 --- a/stubs/sympy-stubs/polys/domains/algebraicfield.pyi +++ b/stubs/sympy-stubs/polys/domains/algebraicfield.pyi @@ -1,7 +1,10 @@ +from typing import Any + from sympy.polys.domains.characteristiczero import CharacteristicZero from sympy.polys.domains.field import Field from sympy.polys.domains.simpledomain import SimpleDomain from sympy.polys.polyclasses import ANP +from sympy.series import Order from sympy.utilities import public @public diff --git a/stubs/sympy-stubs/polys/domains/complexfield.pyi b/stubs/sympy-stubs/polys/domains/complexfield.pyi index 9078d301..35c6b5b1 100644 --- a/stubs/sympy-stubs/polys/domains/complexfield.pyi +++ b/stubs/sympy-stubs/polys/domains/complexfield.pyi @@ -1,3 +1,5 @@ +from typing import Any, Literal + from sympy.polys.domains.characteristiczero import CharacteristicZero from sympy.polys.domains.field import Field from sympy.polys.domains.simpledomain import SimpleDomain diff --git a/stubs/sympy-stubs/polys/domains/expressiondomain.pyi b/stubs/sympy-stubs/polys/domains/expressiondomain.pyi index e0f208b9..e3085ab8 100644 --- a/stubs/sympy-stubs/polys/domains/expressiondomain.pyi +++ b/stubs/sympy-stubs/polys/domains/expressiondomain.pyi @@ -1,3 +1,6 @@ +from types import NotImplementedType +from typing_extensions import Self + from sympy.polys.domains.characteristiczero import CharacteristicZero from sympy.polys.domains.domainelement import DomainElement from sympy.polys.domains.field import Field @@ -25,9 +28,9 @@ class ExpressionDomain(Field, CharacteristicZero, SimpleDomain): def __neg__(f) -> Self: ... def __add__(f, g) -> NotImplementedType | Self: ... def __radd__(f, g) -> Self: ... - def __sub__(f, g) -> NotImplementedType | Self | Expression: ... + def __sub__(f, g) -> NotImplementedType | Self: ... def __rsub__(f, g) -> Self: ... - def __mul__(f, g) -> NotImplementedType | Any | Self: ... + def __mul__(f, g) -> NotImplementedType | Self: ... # | Expression def __rmul__(f, g) -> Self: ... def __pow__(f, n) -> Self | NotImplementedType: ... def __truediv__(f, g) -> Self | NotImplementedType: ... diff --git a/stubs/sympy-stubs/polys/domains/expressionrawdomain.pyi b/stubs/sympy-stubs/polys/domains/expressionrawdomain.pyi index 4dd5d7bf..e1383580 100644 --- a/stubs/sympy-stubs/polys/domains/expressionrawdomain.pyi +++ b/stubs/sympy-stubs/polys/domains/expressionrawdomain.pyi @@ -1,7 +1,10 @@ +from typing_extensions import Self + from sympy.core import Expr from sympy.polys.domains.characteristiczero import CharacteristicZero from sympy.polys.domains.field import Field from sympy.polys.domains.simpledomain import SimpleDomain +from sympy.series import Order from sympy.utilities import public @public diff --git a/stubs/sympy-stubs/printing/lambdarepr.pyi b/stubs/sympy-stubs/printing/lambdarepr.pyi index 2480b91b..4ee84351 100644 --- a/stubs/sympy-stubs/printing/lambdarepr.pyi +++ b/stubs/sympy-stubs/printing/lambdarepr.pyi @@ -1,9 +1,8 @@ from typing import Any +from sympy.printing.numpy import NumPyPrinter # NumPyPrinter is imported for backward compatibility from sympy.printing.pycode import MpmathPrinter, PythonCodePrinter -from .numpy import NumPyPrinter # NumPyPrinter is imported for backward compatibility - __all__ = [ "PythonCodePrinter", "MpmathPrinter", # MpmathPrinter is published for backward compatibility diff --git a/stubs/sympy-stubs/stats/rv_interface.pyi b/stubs/sympy-stubs/stats/rv_interface.pyi index eb3862fa..02e26c1b 100644 --- a/stubs/sympy-stubs/stats/rv_interface.pyi +++ b/stubs/sympy-stubs/stats/rv_interface.pyi @@ -9,10 +9,7 @@ from sympy.core.power import Pow from sympy.core.relational import Ne, Relational from sympy.series.order import Order from sympy.sets.sets import FiniteSet, Set -from sympy.stats.symbolic_multivariate_probability import CrossCovarianceMatrix, ExpectationMatrix, VarianceMatrix -from sympy.stats.symbolic_probability import CentralMoment, Covariance, Expectation, Moment, Variance - -from .rv import ( +from sympy.stats.rv import ( PSpace, cdf, characteristic_function, @@ -33,6 +30,8 @@ from .rv import ( sampling_density, where, ) +from sympy.stats.symbolic_multivariate_probability import CrossCovarianceMatrix, ExpectationMatrix, VarianceMatrix +from sympy.stats.symbolic_probability import CentralMoment, Covariance, Expectation, Moment, Variance __all__ = [ "P", diff --git a/stubs/vispy/visuals/shaders/variable.pyi b/stubs/vispy/visuals/shaders/variable.pyi index 815b7bb4..bc863c91 100644 --- a/stubs/vispy/visuals/shaders/variable.pyi +++ b/stubs/vispy/visuals/shaders/variable.pyi @@ -5,6 +5,7 @@ from typing import Literal # Distributed under the (new) BSD License. See LICENSE.txt for more info. import numpy as np +from ...gloo.globject import GLObject from .shader_object import ShaderObject VARIABLE_TYPES = ...