diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c0304b4..0d09ce44 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -45,10 +45,10 @@ jobs: - name: Check out code uses: actions/checkout@v2 - - name: Run Ruff + - name: Run Ruff Linter uses: astral-sh/ruff-action@v1 - - name: Run Black - uses: psf/black@stable + - name: Run Ruff Formatter + uses: astral-sh/ruff-action@v1 with: - options: "--check --verbose" + args: "format --check" diff --git a/pyproject.toml b/pyproject.toml index b1472650..72b4fe83 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,8 +1,3 @@ -[tool.black] -line_length = 130 -# Target oldest supported Python version -target_version = ["py39"] - [tool.ruff] line-length = 130 # Target oldest supported Python version diff --git a/stubs/matplotlib/transforms.pyi b/stubs/matplotlib/transforms.pyi index 1abc8ab4..792c88c6 100644 --- a/stubs/matplotlib/transforms.pyi +++ b/stubs/matplotlib/transforms.pyi @@ -29,8 +29,7 @@ class TransformNode: class BboxBase(TransformNode): is_bbox = ... is_affine = ... - if DEBUG: - ... + if DEBUG: ... def frozen(self): ... def __array__(self, *args, **kwargs): ... diff --git a/stubs/networkx/classes/multidigraph.pyi b/stubs/networkx/classes/multidigraph.pyi index 596bfb15..b77d69fe 100644 --- a/stubs/networkx/classes/multidigraph.pyi +++ b/stubs/networkx/classes/multidigraph.pyi @@ -18,7 +18,6 @@ class MultiDiGraph(MultiGraph, DiGraph): # adjlist_inner_dict_factory = dict edge_key_dict_factory = ... # edge_attr_dict_factory = dict - def __init__(self, incoming_graph_data=None, multigraph_input=None, **attr): ... @cached_property def adj(self): ... diff --git a/stubs/networkx/classes/multigraph.pyi b/stubs/networkx/classes/multigraph.pyi index 1ea421cf..5fcfc0c7 100644 --- a/stubs/networkx/classes/multigraph.pyi +++ b/stubs/networkx/classes/multigraph.pyi @@ -18,7 +18,6 @@ class MultiGraph(Graph): # adjlist_inner_dict_factory = dict edge_key_dict_factory = ... # edge_attr_dict_factory = dict - def to_directed_class(self): ... def to_undirected_class(self): ... def __init__(self, incoming_graph_data=None, multigraph_input=None, **attr): ... diff --git a/stubs/sklearn/decomposition/_pca.pyi b/stubs/sklearn/decomposition/_pca.pyi index b268d88a..77f7a8b3 100644 --- a/stubs/sklearn/decomposition/_pca.pyi +++ b/stubs/sklearn/decomposition/_pca.pyi @@ -57,7 +57,7 @@ class PCA(_BasePCA): # TODO(1.4): remove in 1.4 # mypy error: Decorated property not supported @deprecated( # type: ignore - "Attribute `n_features_` was deprecated in version 1.2 and will be " "removed in 1.4. Use `n_features_in_` instead." + "Attribute `n_features_` was deprecated in version 1.2 and will be removed in 1.4. Use `n_features_in_` instead." ) @property def n_features_(self) -> int: ... diff --git a/stubs/sklearn/ensemble/_base.pyi b/stubs/sklearn/ensemble/_base.pyi index 7afad2c7..30293fbe 100644 --- a/stubs/sklearn/ensemble/_base.pyi +++ b/stubs/sklearn/ensemble/_base.pyi @@ -38,7 +38,7 @@ class BaseEnsemble(MetaEstimatorMixin, BaseEstimator, metaclass=ABCMeta): # TODO(1.4): remove # mypy error: Decorated property not supported @deprecated( # type: ignore - "Attribute `base_estimator_` was deprecated in version 1.2 and will be removed " "in 1.4. Use `estimator_` instead." + "Attribute `base_estimator_` was deprecated in version 1.2 and will be removed in 1.4. Use `estimator_` instead." ) @property def base_estimator_(self) -> BaseEstimator: ... diff --git a/stubs/sklearn/svm/_classes.pyi b/stubs/sklearn/svm/_classes.pyi index da7862aa..b9394c51 100644 --- a/stubs/sklearn/svm/_classes.pyi +++ b/stubs/sklearn/svm/_classes.pyi @@ -197,7 +197,7 @@ class SVR(RegressorMixin, BaseLibSVM): ) -> None: ... # TODO(1.4): Remove - @deprecated("Attribute `class_weight_` was deprecated in version 1.2 and will be removed in" " 1.4.") # type: ignore + @deprecated("Attribute `class_weight_` was deprecated in version 1.2 and will be removed in 1.4.") # type: ignore @property def class_weight_(self) -> ndarray: ... @@ -237,7 +237,7 @@ class NuSVR(RegressorMixin, BaseLibSVM): ) -> None: ... # TODO(1.4): Remove - @deprecated("Attribute `class_weight_` was deprecated in version 1.2 and will be removed in" " 1.4.") # type: ignore + @deprecated("Attribute `class_weight_` was deprecated in version 1.2 and will be removed in 1.4.") # type: ignore @property def class_weight_(self) -> ndarray: ... @@ -277,7 +277,7 @@ class OneClassSVM(OutlierMixin, BaseLibSVM): ) -> None: ... # TODO(1.4): Remove - @deprecated("Attribute `class_weight_` was deprecated in version 1.2 and will be removed in" " 1.4.") # type: ignore + @deprecated("Attribute `class_weight_` was deprecated in version 1.2 and will be removed in 1.4.") # type: ignore @property def class_weight_(self) -> ndarray: ... def fit( diff --git a/stubs/sklearn/utils/discovery.pyi b/stubs/sklearn/utils/discovery.pyi index 44558323..cd24fb97 100644 --- a/stubs/sklearn/utils/discovery.pyi +++ b/stubs/sklearn/utils/discovery.pyi @@ -24,7 +24,7 @@ def all_estimators( None | Sequence[Literal["classifier", "regressor", "cluster", "transformer"]] | Literal["classifier", "regressor", "cluster", "transformer"] - ) = None + ) = None, ) -> ndarray: ... def all_displays() -> ndarray: ... def all_functions() -> ndarray: ... diff --git a/stubs/sympy-stubs/__init__.pyi b/stubs/sympy-stubs/__init__.pyi index 43a8aa94..85ada095 100644 --- a/stubs/sympy-stubs/__init__.pyi +++ b/stubs/sympy-stubs/__init__.pyi @@ -921,8 +921,7 @@ from sympy.utilities import ( xthreaded, ) -if sys.version_info < (3, 8): - ... +if sys.version_info < (3, 8): ... if "dev" in __version__: def enable_warnings() -> None: ... diff --git a/stubs/sympy-stubs/assumptions/assume.pyi b/stubs/sympy-stubs/assumptions/assume.pyi index 8f5da1be..073e6676 100644 --- a/stubs/sympy-stubs/assumptions/assume.pyi +++ b/stubs/sympy-stubs/assumptions/assume.pyi @@ -25,7 +25,6 @@ class AppliedPredicate(Boolean): class PredicateMeta(type): def __new__(cls, clsname, bases, dct) -> Self: # type: ignore ... - @property def __doc__(cls): ... diff --git a/stubs/sympy-stubs/combinatorics/partitions.pyi b/stubs/sympy-stubs/combinatorics/partitions.pyi index 167d3d33..24cbf3c0 100644 --- a/stubs/sympy-stubs/combinatorics/partitions.pyi +++ b/stubs/sympy-stubs/combinatorics/partitions.pyi @@ -9,7 +9,9 @@ class Partition(FiniteSet): _rank = ... _partition = ... def __new__(cls, *partition) -> Self: ... - def sort_key(self, order=...) -> tuple[ + def sort_key( + self, order=... + ) -> tuple[ tuple[tuple[Literal[5], Literal[0], str], tuple[int, tuple[Any, ...]], Any, Any] | Any | tuple[ diff --git a/stubs/sympy-stubs/core/expr.pyi b/stubs/sympy-stubs/core/expr.pyi index 6b11a644..fddb502d 100644 --- a/stubs/sympy-stubs/core/expr.pyi +++ b/stubs/sympy-stubs/core/expr.pyi @@ -19,7 +19,9 @@ class Expr(Basic, EvalfMixin): __slots__: tuple[str, ...] = ... is_scalar = ... @cacheit - def sort_key(self, order=...) -> tuple[ + def sort_key( + self, order=... + ) -> tuple[ tuple[Literal[5], Literal[0], str] | Any, tuple[ int, diff --git a/stubs/sympy-stubs/core/function.pyi b/stubs/sympy-stubs/core/function.pyi index 1c7db3e9..5704b612 100644 --- a/stubs/sympy-stubs/core/function.pyi +++ b/stubs/sympy-stubs/core/function.pyi @@ -70,7 +70,6 @@ _undef_sage_helper = ... class UndefinedFunction(FunctionClass): def __new__(cls, name, bases=..., __dict__=..., **kwargs) -> Self: # type: ignore ... - def __instancecheck__(cls, instance) -> bool: ... _kwargs: dict[str, bool | None] = ... diff --git a/stubs/sympy-stubs/geometry/polygon.pyi b/stubs/sympy-stubs/geometry/polygon.pyi index 4eb6ea7a..539589f3 100644 --- a/stubs/sympy-stubs/geometry/polygon.pyi +++ b/stubs/sympy-stubs/geometry/polygon.pyi @@ -41,7 +41,9 @@ class Polygon(GeometrySet): def parameter_value(self, other, t) -> dict[Any, Any]: ... def plot_interval(self, parameter=...) -> list[Any]: ... def intersection(self, o) -> list[Any]: ... - def cut_section(self, line) -> tuple[ + def cut_section( + self, line + ) -> tuple[ RegularPolygon | Polygon | Triangle | Point | Point2D | Point3D | Segment2D | Segment3D | Segment | None, RegularPolygon | Polygon | Triangle | Point | Point2D | Point3D | Segment2D | Segment3D | Segment | None, ]: ... diff --git a/stubs/sympy-stubs/plotting/pygletplot/managed_window.pyi b/stubs/sympy-stubs/plotting/pygletplot/managed_window.pyi index 2558a9c0..262ea0c5 100644 --- a/stubs/sympy-stubs/plotting/pygletplot/managed_window.pyi +++ b/stubs/sympy-stubs/plotting/pygletplot/managed_window.pyi @@ -10,5 +10,4 @@ class ManagedWindow: def update(self, dt) -> None: ... def draw(self) -> None: ... -if __name__ == "__main__": - ... +if __name__ == "__main__": ... diff --git a/stubs/sympy-stubs/plotting/pygletplot/util.pyi b/stubs/sympy-stubs/plotting/pygletplot/util.pyi index 9cb51157..946c9657 100644 --- a/stubs/sympy-stubs/plotting/pygletplot/util.pyi +++ b/stubs/sympy-stubs/plotting/pygletplot/util.pyi @@ -6,11 +6,13 @@ def get_projection_matrix(array_type=..., glGetMethod=...) -> Array[c_float]: .. def get_viewport() -> Array[c_int]: ... def get_direction_vectors() -> tuple[tuple[Any, Any, Any], tuple[Any, Any, Any], tuple[Any, Any, Any]]: ... def get_view_direction_vectors() -> tuple[tuple[Any, Any, Any], tuple[Any, Any, Any], tuple[Any, Any, Any]]: ... -def get_basis_vectors() -> tuple[ - tuple[Literal[1], Literal[0], Literal[0]], - tuple[Literal[0], Literal[1], Literal[0]], - tuple[Literal[0], Literal[0], Literal[1]], -]: ... +def get_basis_vectors() -> ( + tuple[ + tuple[Literal[1], Literal[0], Literal[0]], + tuple[Literal[0], Literal[1], Literal[0]], + tuple[Literal[0], Literal[0], Literal[1]], + ] +): ... def screen_to_model(x, y, z) -> tuple[float, float, float]: ... def model_to_screen(x, y, z) -> tuple[float, float, float]: ... def vec_subs(a, b) -> tuple[Any, ...]: ... diff --git a/stubs/sympy-stubs/polys/densearith.pyi b/stubs/sympy-stubs/polys/densearith.pyi index b2c86a25..706d54ae 100644 --- a/stubs/sympy-stubs/polys/densearith.pyi +++ b/stubs/sympy-stubs/polys/densearith.pyi @@ -40,7 +40,9 @@ def dup_pdiv(f, g, K) -> tuple[list[Any], Any] | tuple[list[Any], list[Any]]: .. def dup_prem(f, g, K) -> list[Any]: ... def dup_pquo(f, g, K) -> list[Any]: ... def dup_pexquo(f, g, K) -> list[Any]: ... -def dmp_pdiv(f, g, u, K) -> ( +def dmp_pdiv( + f, g, u, K +) -> ( tuple[list[Any], Any] | tuple[list[Any], list[Any]] | tuple[list[list[Any]], Any] diff --git a/stubs/sympy-stubs/polys/distributedmodules.pyi b/stubs/sympy-stubs/polys/distributedmodules.pyi index d2990b0f..b7528911 100644 --- a/stubs/sympy-stubs/polys/distributedmodules.pyi +++ b/stubs/sympy-stubs/polys/distributedmodules.pyi @@ -22,7 +22,9 @@ def sdm_spoly( f, g, O, K, phantom=... ) -> list[Any] | list[tuple[Any, Any]] | tuple[list[tuple[Any, Any]], list[tuple[Any, Any]]]: ... def sdm_ecart(f) -> int: ... -def sdm_nf_mora(f, G, O, K, phantom=...) -> ( +def sdm_nf_mora( + f, G, O, K, phantom=... +) -> ( tuple[ Any | tuple[Any, Any] | list[tuple[Any, Any]] | list[Any] | tuple[list[tuple[Any, Any]], list[tuple[Any, Any]]], Any | tuple[Any, Any] | list[tuple[Any, Any]], @@ -32,7 +34,9 @@ def sdm_nf_mora(f, G, O, K, phantom=...) -> ( | list[Any] | tuple[list[tuple[Any, Any]], list[tuple[Any, Any]]] ): ... -def sdm_nf_buchberger(f, G, O, K, phantom=...) -> ( +def sdm_nf_buchberger( + f, G, O, K, phantom=... +) -> ( tuple[ Any | tuple[Any, Any] | list[tuple[Any, Any]] | list[Any] | tuple[list[tuple[Any, Any]], list[tuple[Any, Any]]], Any | tuple[Any, Any] | list[tuple[Any, Any]], diff --git a/stubs/sympy-stubs/polys/numberfields/galois_resolvents.pyi b/stubs/sympy-stubs/polys/numberfields/galois_resolvents.pyi index 0232517f..b71009dc 100644 --- a/stubs/sympy-stubs/polys/numberfields/galois_resolvents.pyi +++ b/stubs/sympy-stubs/polys/numberfields/galois_resolvents.pyi @@ -16,14 +16,16 @@ class Resolvent: def wrap(text, width=...) -> LiteralString | Literal[""]: ... def s_vars(n) -> Any: ... def sparse_symmetrize_resolvent_coeffs(F, X, s, verbose=...) -> tuple[list[Any], list[Any]]: ... -def define_resolvents() -> dict[ - tuple[Literal[4], Literal[0]] - | tuple[Literal[4], Literal[1]] - | tuple[Literal[5], Literal[1]] - | tuple[Literal[6], Literal[1]] - | tuple[Literal[6], Literal[2]], - Any, -]: ... +def define_resolvents() -> ( + dict[ + tuple[Literal[4], Literal[0]] + | tuple[Literal[4], Literal[1]] + | tuple[Literal[5], Literal[1]] + | tuple[Literal[6], Literal[1]] + | tuple[Literal[6], Literal[2]], + Any, + ] +): ... def generate_lambda_lookup(verbose=..., trial_run=...) -> str: ... def get_resolvent_by_lookup(T, number) -> list[Any]: ... diff --git a/stubs/sympy-stubs/polys/polyclasses.pyi b/stubs/sympy-stubs/polys/polyclasses.pyi index c28b8311..94be1cff 100644 --- a/stubs/sympy-stubs/polys/polyclasses.pyi +++ b/stubs/sympy-stubs/polys/polyclasses.pyi @@ -206,7 +206,9 @@ class DMF(PicklableWithSlots, CantSympify): tuple[Any, Any, Callable[..., Any | Self], tuple[Any | list[Any], Any | list[Any]], list[Any] | Any | list[list[Any]]] | tuple[Any, Any, Callable[..., Any | Self], tuple[Any | list[list[Any]], Any | list[list[Any]]], Any | list[list[Any]]] ): ... - def frac_unify(f, g) -> ( + def frac_unify( + f, g + ) -> ( tuple[ Any, Any, Callable[..., Any | Self], tuple[Any | list[Any], Any | list[Any]], tuple[Any | list[Any], Any | list[Any]] ] diff --git a/stubs/sympy-stubs/polys/polytools.pyi b/stubs/sympy-stubs/polys/polytools.pyi index 4dfd5ba0..541afda0 100644 --- a/stubs/sympy-stubs/polys/polytools.pyi +++ b/stubs/sympy-stubs/polys/polytools.pyi @@ -180,7 +180,9 @@ class Poly(Basic): def same_root(f, a, b): ... def cancel(f, g, include=...) -> tuple[Any, Any | Self, Any | Self] | tuple[Any | Self, ...]: ... def make_monic_over_integers_by_scaling_roots(f) -> tuple[Self, Any] | tuple[Any | Self, Any]: ... - def galois_group(f, by_name=..., max_tries=..., randomize=...) -> tuple[ + def galois_group( + f, by_name=..., max_tries=..., randomize=... + ) -> tuple[ PermutationGroup | Literal[ # Looks like a false-positives, no code to specify diff --git a/stubs/sympy-stubs/polys/sqfreetools.pyi b/stubs/sympy-stubs/polys/sqfreetools.pyi index b06b520d..61783a1b 100644 --- a/stubs/sympy-stubs/polys/sqfreetools.pyi +++ b/stubs/sympy-stubs/polys/sqfreetools.pyi @@ -2,7 +2,9 @@ from typing import Any, Literal def dup_sqf_p(f, K) -> bool: ... def dmp_sqf_p(f, u, K) -> bool: ... -def dup_sqf_norm(f, K) -> tuple[ +def dup_sqf_norm( + f, K +) -> tuple[ int, Any | list[Any], tuple[Any, list[Any]] @@ -12,7 +14,9 @@ def dup_sqf_norm(f, K) -> tuple[ | list[list[Any]] | list[Any], ]: ... -def dmp_sqf_norm(f, u, K) -> ( +def dmp_sqf_norm( + f, u, K +) -> ( tuple[ int, Any | list[Any], diff --git a/stubs/sympy-stubs/simplify/fu.pyi b/stubs/sympy-stubs/simplify/fu.pyi index dd24b317..4727aa01 100644 --- a/stubs/sympy-stubs/simplify/fu.pyi +++ b/stubs/sympy-stubs/simplify/fu.pyi @@ -29,8 +29,7 @@ def TR22(rv, max=..., pow=...): ... def TRpower(rv): ... def L(rv): ... -if SYMPY_DEBUG: - ... +if SYMPY_DEBUG: ... CTR1 = ... CTR2 = ... CTR3 = ... diff --git a/stubs/sympy-stubs/tensor/array/expressions/from_array_to_matrix.pyi b/stubs/sympy-stubs/tensor/array/expressions/from_array_to_matrix.pyi index e6b79809..a1e35e87 100644 --- a/stubs/sympy-stubs/tensor/array/expressions/from_array_to_matrix.pyi +++ b/stubs/sympy-stubs/tensor/array/expressions/from_array_to_matrix.pyi @@ -79,7 +79,7 @@ def _(expr: ElementwiseApplyFunction) -> tuple[Any, list[Any]] | tuple[MatrixExp def _(expr: ArrayElementwiseApplyFunc) -> tuple[ArrayElementwiseApplyFunc, list[Any]]: ... def convert_array_to_matrix(expr): ... def identify_hadamard_products( - expr: tUnion[ArrayContraction, ArrayDiagonal] + expr: tUnion[ArrayContraction, ArrayDiagonal], ) -> ZeroArray | ArrayTensorProduct | ArrayContraction | Basic | PermuteDims: ... def identify_removable_identity_matrices(expr) -> ZeroArray | ArrayTensorProduct | ArrayContraction | Basic | PermuteDims: ... def remove_identity_matrices( diff --git a/stubs/sympy-stubs/testing/runtests.pyi b/stubs/sympy-stubs/testing/runtests.pyi index 8935ca7d..ee9df77f 100644 --- a/stubs/sympy-stubs/testing/runtests.pyi +++ b/stubs/sympy-stubs/testing/runtests.pyi @@ -12,8 +12,7 @@ class Skipped(Exception): ... class TimeOutError(Exception): ... class DependencyError(Exception): ... -if IS_WINDOWS: - ... +if IS_WINDOWS: ... def convert_to_native_paths(lst) -> list[Any]: ... def get_sympy_dir() -> str: ... diff --git a/utils/validate_stubs.py b/utils/validate_stubs.py index 169bc5c3..477ededf 100644 --- a/utils/validate_stubs.py +++ b/utils/validate_stubs.py @@ -13,7 +13,7 @@ --path= Where to find stubs (default to parent directory) --function= Restrict to the named function (or method if used with --class). --class= Restrict to the named class. - """ +""" import importlib import inspect