diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 6fddca0..6c4b369 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -5,3 +5,7 @@ updates: directory: "/" schedule: interval: "weekly" + groups: + actions: + patterns: + - "*" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 517a4a9..c95a60a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,7 +5,7 @@ ci: repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-added-large-files - id: check-case-conflict @@ -21,31 +21,15 @@ repos: - id: name-tests-test args: ["--pytest-test-first"] -- repo: https://github.com/asottile/setup-cfg-fmt - rev: v2.4.0 - hooks: - - id: setup-cfg-fmt - args: [--include-version-classifiers, --max-py-version=3.11] - -- repo: https://github.com/psf/black-pre-commit-mirror - rev: 23.9.1 - hooks: - - id: black - -- repo: https://github.com/cheshirekow/cmake-format-precommit - rev: v0.6.13 - hooks: - - id: cmake-format - additional_dependencies: [pyyaml] - - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.291 + rev: v0.1.15 hooks: - id: ruff args: ["--fix", "--show-fixes"] + - id: ruff-format - repo: https://github.com/codespell-project/codespell - rev: v2.2.5 + rev: v2.2.6 hooks: - id: codespell args: ["-L", "ue,subjet,parms,fo,numer,thre,gaus"] @@ -59,11 +43,6 @@ repos: exclude: .pre-commit-config.yaml - repo: https://github.com/shellcheck-py/shellcheck-py - rev: "v0.9.0.5" + rev: "v0.9.0.6" hooks: - id: shellcheck - -- repo: https://github.com/asottile/pyupgrade - rev: v3.13.0 - hooks: - - id: pyupgrade diff --git a/docs/source/conf.py b/docs/source/conf.py index 6e33f91..d54d90a 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -10,7 +10,7 @@ import os import sys -sys.path.insert(0, os.path.abspath("../../odapt/")) # noqa: PTH100 +sys.path.insert(0, os.path.abspath("../../odapt/")) project = "odapt" diff --git a/docs/source/prepare_docstrings.py b/docs/source/prepare_docstrings.py index b8a9be8..cf86d5c 100644 --- a/docs/source/prepare_docstrings.py +++ b/docs/source/prepare_docstrings.py @@ -27,7 +27,7 @@ ] latest_commit = ( - subprocess.run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE) + subprocess.run(["git", "rev-parse", "HEAD"], stdout=subprocess.PIPE, check=False) .stdout.decode("utf-8") .strip() ) @@ -37,9 +37,7 @@ :caption: Main Interface :hidden: -{}""".format( - "".join(f" {x}\n" for x in common) - ) +{}""".format("".join(f" {x}\n" for x in common)) ) toctree = open("odapt.toctree", "w") toctree.write( @@ -71,9 +69,7 @@ def handle_module(modulename, module): {1} .. automodule:: {0} -""".format( - modulename, "=" * len(modulename) - ) +""".format(modulename, "=" * len(modulename)) ensure(modulename + ".rst", content) if toctree2 is None: toctree.write(" " + modulename + " (module) <" + modulename + ">\n") @@ -201,13 +197,9 @@ def prettymro(c): +-{}-+ | **Inheritance order:** {}| +={}=+ - | """.format( - "-" * longest_cell, " " * (longest_cell - 22), "=" * longest_cell - ) + | """.format("-" * longest_cell, " " * (longest_cell - 22), "=" * longest_cell) inheritance_footer = """ | - +-{}-+""".format( - "-" * longest_cell - ) + +-{}-+""".format("-" * longest_cell) inheritance = [x + " " * (longest_cell - len(x)) for x in inheritance] inheritance_sep = """ | | """ @@ -266,9 +258,7 @@ def handle_function(functionname, cls): Defined in {} on {}. .. autofunction:: {} -""".format( - title, "=" * len(title), link, linelink, functionname - ) +""".format(title, "=" * len(title), link, linelink, functionname) ensure(functionname + ".rst", content) if upfront or toctree2 is None: if functionname not in common: @@ -288,9 +278,7 @@ def handle_function(functionname, cls): :caption: {} :hidden: -""".format( - modulename.replace("odapt.", "") - ) +""".format(modulename.replace("odapt.", "")) ) handle_module(modulename, module) diff --git a/pyproject.toml b/pyproject.toml index 8b6bfbe..dbae84b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -65,8 +65,6 @@ source = "vcs" [tool.hatch.build.hooks.vcs] version-file = "src/odapt/_version.py" -[tool.hatch.metadata.hooks.vcs] - [tool.pytest.ini_options] minversion = "6.0" addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] @@ -93,7 +91,6 @@ files = ["src", "tests"] python_version = "3.8" warn_unused_configs = true strict = true -show_error_codes = true enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] warn_unreachable = true disallow_untyped_defs = false @@ -106,15 +103,17 @@ disallow_incomplete_defs = true [tool.ruff] -select = [ - "E", "F", "W", # flake8 +src = ["src"] + + +[tool.ruff.lint] +extend-select = [ "B", # flake8-bugbear "I", # isort "ARG", # flake8-unused-arguments "C4", # flake8-comprehensions "EM", # flake8-errmsg "ICN", # flake8-import-conventions - "ISC", # flake8-implicit-str-concat "G", # flake8-logging-format "PGH", # pygrep-hooks "PIE", # flake8-pie @@ -131,27 +130,18 @@ select = [ "NPY", # NumPy specific rules "PD", # pandas-vet ] -extend-ignore = [ - "PLR", # Design related pylint codes - "E501", # Line too long -] -src = ["src"] -unfixable = [ - "T20", # Removes print statements - "F841", # Removes unused variables +ignore = [ + "PLR09", # Too many ... + "PLR2004", # Magic value used in comparison ] -exclude = [ - "tests/*.py", - "src/odapt/__init__.py", - "docs/*.py"] flake8-unused-arguments.ignore-variadic-names = true isort.required-imports = ["from __future__ import annotations"] -# Uncomment if using a _compat.typing backport -# typing-modules = ["odapt._compat.typing"] -[tool.ruff.per-file-ignores] -"tests/**" = ["T20"] +[tool.ruff.lint.per-file-ignores] +"tests/**" = ["T20", "SIM118"] +"docs/**" = ["SIM", "PTH", "B023", "RET"] "noxfile.py" = ["T20"] +"tests/test_copy_root.py" = ["F821", "F841"] [tool.pylint] diff --git a/src/odapt/__init__.py b/src/odapt/__init__.py index 1cc0a9b..4cf996e 100644 --- a/src/odapt/__init__.py +++ b/src/odapt/__init__.py @@ -6,11 +6,17 @@ from __future__ import annotations from odapt._version import __version__ +from odapt.copy_root import copy_root +from odapt.histogram_adding import hadd +from odapt.merge import hadd_and_merge +from odapt.parquet_to_root import parquet_to_root +from odapt.root_to_parquet import root_to_parquet -from odapt.histogram_adding import hadd # noqa: F401 -from odapt.merge import hadd_and_merge # noqa: F401 -from odapt.copy_root import copy_root # noqa: F401 -from odapt.parquet_to_root import parquet_to_root # noqa: F401 -from odapt.root_to_parquet import root_to_parquet # noqa: F401 - -__all__ = ["__version__"] +__all__ = [ + "__version__", + "hadd", + "hadd_and_merge", + "copy_root", + "parquet_to_root", + "root_to_parquet", +] diff --git a/tests/test_copy_root.py b/tests/test_copy_root.py index ac5c603..c9eed20 100644 --- a/tests/test_copy_root.py +++ b/tests/test_copy_root.py @@ -1,7 +1,10 @@ -import uproot -import odapt as od +from __future__ import annotations + import awkward as ak import pytest +import uproot + +import odapt as od skhep_testdata = pytest.importorskip("skhep_testdata") @@ -35,7 +38,7 @@ def test_drop_branch(): assert "Jet_Px" not in file["events"] for key in original["events"].keys(): - if key != "MClepton_py" and key != "Jet_Px": + if key not in {"MClepton_py", "Jet_Px"}: assert key in file["events"].keys() assert ak.all( file["events"][key].array() == original["events"][key].array() diff --git a/tests/test_parquet_to_root.py b/tests/test_parquet_to_root.py index d8f6233..4f7f3e4 100644 --- a/tests/test_parquet_to_root.py +++ b/tests/test_parquet_to_root.py @@ -1,7 +1,10 @@ -import uproot -from odapt.parquet_to_root import parquet_to_root +from __future__ import annotations + import awkward as ak import pytest +import uproot + +from odapt.parquet_to_root import parquet_to_root skhep_testdata = pytest.importorskip("skhep_testdata") @@ -57,7 +60,7 @@ def test_hzz(): cur_group += 1 edit = tree.arrays() - chunks = {name: array for name, array in zip(ak.fields(edit), ak.unzip(edit))} + chunks = dict(zip(ak.fields(edit), ak.unzip(edit))) for key in count_branches: del chunks[key] for group in groups: diff --git a/tests/test_root_to_parquet.py b/tests/test_root_to_parquet.py index 77b2ec6..92717a2 100644 --- a/tests/test_root_to_parquet.py +++ b/tests/test_root_to_parquet.py @@ -1,7 +1,10 @@ -import uproot +from __future__ import annotations + import awkward as ak -import odapt as od import pytest +import uproot + +import odapt as od skhep_testdata = pytest.importorskip("skhep_testdata")