Skip to content

Commit

Permalink
Switch from Black to Ruff (#328)
Browse files Browse the repository at this point in the history
* Reformat with Ruff

* Undocumented black deviations
  • Loading branch information
Avasam authored Nov 7, 2024
1 parent f33aa54 commit 7e9bfa9
Show file tree
Hide file tree
Showing 27 changed files with 64 additions and 54 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions stubs/matplotlib/transforms.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
Expand Down
1 change: 0 additions & 1 deletion stubs/networkx/classes/multidigraph.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
Expand Down
1 change: 0 additions & 1 deletion stubs/networkx/classes/multigraph.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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): ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/sklearn/decomposition/_pca.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/sklearn/ensemble/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
6 changes: 3 additions & 3 deletions stubs/sklearn/svm/_classes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...

Expand Down Expand Up @@ -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: ...

Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion stubs/sklearn/utils/discovery.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
3 changes: 1 addition & 2 deletions stubs/sympy-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...

Expand Down
1 change: 0 additions & 1 deletion stubs/sympy-stubs/assumptions/assume.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class AppliedPredicate(Boolean):
class PredicateMeta(type):
def __new__(cls, clsname, bases, dct) -> Self: # type: ignore
...

@property
def __doc__(cls): ...

Expand Down
4 changes: 3 additions & 1 deletion stubs/sympy-stubs/combinatorics/partitions.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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[
Expand Down
4 changes: 3 additions & 1 deletion stubs/sympy-stubs/core/expr.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion stubs/sympy-stubs/core/function.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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] = ...
Expand Down
4 changes: 3 additions & 1 deletion stubs/sympy-stubs/geometry/polygon.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]: ...
Expand Down
3 changes: 1 addition & 2 deletions stubs/sympy-stubs/plotting/pygletplot/managed_window.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ class ManagedWindow:
def update(self, dt) -> None: ...
def draw(self) -> None: ...

if __name__ == "__main__":
...
if __name__ == "__main__": ...
12 changes: 7 additions & 5 deletions stubs/sympy-stubs/plotting/pygletplot/util.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...]: ...
Expand Down
4 changes: 3 additions & 1 deletion stubs/sympy-stubs/polys/densearith.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 6 additions & 2 deletions stubs/sympy-stubs/polys/distributedmodules.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]],
Expand All @@ -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]],
Expand Down
18 changes: 10 additions & 8 deletions stubs/sympy-stubs/polys/numberfields/galois_resolvents.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]: ...

Expand Down
4 changes: 3 additions & 1 deletion stubs/sympy-stubs/polys/polyclasses.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
]
Expand Down
4 changes: 3 additions & 1 deletion stubs/sympy-stubs/polys/polytools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions stubs/sympy-stubs/polys/sqfreetools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand All @@ -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],
Expand Down
3 changes: 1 addition & 2 deletions stubs/sympy-stubs/simplify/fu.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ def TR22(rv, max=..., pow=...): ...
def TRpower(rv): ...
def L(rv): ...

if SYMPY_DEBUG:
...
if SYMPY_DEBUG: ...
CTR1 = ...
CTR2 = ...
CTR3 = ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions stubs/sympy-stubs/testing/runtests.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
2 changes: 1 addition & 1 deletion utils/validate_stubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
--path=<stubpath> Where to find stubs (default to parent directory)
--function=<f> Restrict to the named function (or method if used with --class).
--class=<c> Restrict to the named class.
"""
"""

import importlib
import inspect
Expand Down

0 comments on commit 7e9bfa9

Please sign in to comment.