From d3a760d34bc0eff08554e6aa3b40fde6e22473be Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sat, 23 Dec 2023 13:06:36 -0500 Subject: [PATCH] chore: repo review updates (#408) * chore: touch up Ruff config Signed-off-by: Henry Schreiner * chore: remove uneeded MyPy config line Signed-off-by: Henry Schreiner * ci: grouped dependabot updates Signed-off-by: Henry Schreiner --------- Signed-off-by: Henry Schreiner --- .github/dependabot.yml | 6 +- pyproject.toml | 25 ++++---- src/vector/backends/_numba_object.py | 87 ++++++++++++++-------------- src/vector/backends/awkward.py | 17 +++--- 4 files changed, 66 insertions(+), 69 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 2c7d1708..6c4b3695 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,4 +4,8 @@ updates: - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "daily" + interval: "weekly" + groups: + actions: + patterns: + - "*" diff --git a/pyproject.toml b/pyproject.toml index 95e72679..7eb7603d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -87,9 +87,11 @@ version.source = "vcs" build.hooks.vcs.version-file = "src/vector/_version.py" [tool.ruff] -select = [ - "E", "F", "W", # flake8 - "B", "B904", # flake8-bugbear +src = ["src"] + +[tool.ruff.lint] +extend-select = [ + "B", # flake8-bugbear "I", # isort "C4", # flake8-comprehensions "ISC", # flake8-implicit-str-concat @@ -103,24 +105,18 @@ select = [ "UP", # pyupgrade "YTT", # flake8-2020 ] -extend-ignore = [ - "PLR", # Design related pylint codes - "E501", # Line too long +ignore = [ + "PLR09", # Too many X + "PLR2004", # Magic values ] typing-modules = ["vector._typeutils"] -src = ["src"] -unfixable = [ - "T20", # Removes print statements - "F841", # Removes unused variables -] -exclude = [] isort.required-imports = ["from __future__ import annotations"] -[tool.ruff.per-file-ignores] +[tool.ruff.lint.per-file-ignores] "noxfile.py" = ["T20"] "tests/*" = ["T20"] "src/vector/backends/_numba_object.py" = ["PGH003"] -"tests/backends/test_operators.py" = ["SIM201", "SIM202"] +"tests/backends/test_operators.py" = ["SIM201", "SIM202", "PLR0124"] [tool.pylint] master.py-version = "3.8" @@ -212,7 +208,6 @@ files = [ python_version = "3.8" strict = true warn_return_any = false -show_error_codes = true enable_error_code = [ "ignore-without-code", "truthy-bool", diff --git a/src/vector/backends/_numba_object.py b/src/vector/backends/_numba_object.py index 358b0543..0ecc905e 100644 --- a/src/vector/backends/_numba_object.py +++ b/src/vector/backends/_numba_object.py @@ -1538,55 +1538,54 @@ def overloader_impl(v1, v2): coord24(v2), ) - else: - if groupname == "planar": - instance_class = flavor_of(v1, v2).ProjectionClass2D - azcoords = _coord_object_type[returns[0]] + elif groupname == "planar": + instance_class = flavor_of(v1, v2).ProjectionClass2D + azcoords = _coord_object_type[returns[0]] - def overloader_impl(v1, v2): - out1, out2 = function( - numpy, coord11(v1), coord12(v1), coord21(v2), coord22(v2) - ) - return instance_class(azcoords(out1, out2)) + def overloader_impl(v1, v2): + out1, out2 = function( + numpy, coord11(v1), coord12(v1), coord21(v2), coord22(v2) + ) + return instance_class(azcoords(out1, out2)) - elif groupname == "spatial": - instance_class = flavor_of(v1, v2).ProjectionClass3D - azcoords = _coord_object_type[returns[0]] - lcoords = _coord_object_type[returns[1]] + elif groupname == "spatial": + instance_class = flavor_of(v1, v2).ProjectionClass3D + azcoords = _coord_object_type[returns[0]] + lcoords = _coord_object_type[returns[1]] - def overloader_impl(v1, v2): - out1, out2, out3 = function( - numpy, - coord11(v1), - coord12(v1), - coord13(v1), - coord21(v2), - coord22(v2), - coord23(v2), - ) - return instance_class(azcoords(out1, out2), lcoords(out3)) + def overloader_impl(v1, v2): + out1, out2, out3 = function( + numpy, + coord11(v1), + coord12(v1), + coord13(v1), + coord21(v2), + coord22(v2), + coord23(v2), + ) + return instance_class(azcoords(out1, out2), lcoords(out3)) - elif groupname == "lorentz": - instance_class = flavor_of(v1, v2).ProjectionClass4D - azcoords = _coord_object_type[returns[0]] - lcoords = _coord_object_type[returns[1]] - tcoords = _coord_object_type[returns[2]] + elif groupname == "lorentz": + instance_class = flavor_of(v1, v2).ProjectionClass4D + azcoords = _coord_object_type[returns[0]] + lcoords = _coord_object_type[returns[1]] + tcoords = _coord_object_type[returns[2]] - def overloader_impl(v1, v2): - out1, out2, out3, out4 = function( - numpy, - coord11(v1), - coord12(v1), - coord13(v1), - coord14(v1), - coord21(v2), - coord22(v2), - coord23(v2), - coord24(v2), - ) - return instance_class( - azcoords(out1, out2), lcoords(out3), tcoords(out4) - ) + def overloader_impl(v1, v2): + out1, out2, out3, out4 = function( + numpy, + coord11(v1), + coord12(v1), + coord13(v1), + coord14(v1), + coord21(v2), + coord22(v2), + coord23(v2), + coord24(v2), + ) + return instance_class( + azcoords(out1, out2), lcoords(out3), tcoords(out4) + ) return overloader_impl diff --git a/src/vector/backends/awkward.py b/src/vector/backends/awkward.py index a138a52c..d1817744 100644 --- a/src/vector/backends/awkward.py +++ b/src/vector/backends/awkward.py @@ -580,17 +580,16 @@ def _class_to_name(cls: type[VectorProtocol]) -> str: if issubclass(cls, Momentum): if issubclass(cls, Vector2D): return "Momentum2D" - elif issubclass(cls, Vector3D): + if issubclass(cls, Vector3D): return "Momentum3D" - elif issubclass(cls, Vector4D): + if issubclass(cls, Vector4D): return "Momentum4D" - else: - if issubclass(cls, Vector2D): - return "Vector2D" - elif issubclass(cls, Vector3D): - return "Vector3D" - elif issubclass(cls, Vector4D): - return "Vector4D" + if issubclass(cls, Vector2D): + return "Vector2D" + if issubclass(cls, Vector3D): + return "Vector3D" + if issubclass(cls, Vector4D): + return "Vector4D" raise AssertionError(repr(cls))