Skip to content

Commit

Permalink
chore: update config and formatters
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Jan 30, 2024
1 parent 294b4e3 commit fb5eed8
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 83 deletions.
4 changes: 4 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ updates:
directory: "/"
schedule:
interval: "weekly"
groups:
actions:
patterns:
- "*"
31 changes: 5 additions & 26 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]
Expand All @@ -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
2 changes: 1 addition & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
26 changes: 7 additions & 19 deletions docs/source/prepare_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
)
Expand All @@ -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(
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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 = """ |
| """
Expand Down Expand Up @@ -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:
Expand All @@ -288,9 +278,7 @@ def handle_function(functionname, cls):
:caption: {}
:hidden:
""".format(
modulename.replace("odapt.", "")
)
""".format(modulename.replace("odapt.", ""))
)

handle_module(modulename, module)
Expand Down
34 changes: 12 additions & 22 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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]
Expand Down
20 changes: 13 additions & 7 deletions src/odapt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
9 changes: 6 additions & 3 deletions tests/test_copy_root.py
Original file line number Diff line number Diff line change
@@ -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")

Expand Down Expand Up @@ -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()
Expand Down
9 changes: 6 additions & 3 deletions tests/test_parquet_to_root.py
Original file line number Diff line number Diff line change
@@ -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")

Expand Down Expand Up @@ -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:
Expand Down
7 changes: 5 additions & 2 deletions tests/test_root_to_parquet.py
Original file line number Diff line number Diff line change
@@ -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")

Expand Down

0 comments on commit fb5eed8

Please sign in to comment.