Skip to content

Commit

Permalink
chore: update pre-commit hooks (#355)
Browse files Browse the repository at this point in the history
* chore: update pre-commit hooks

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.278 → v0.0.280](astral-sh/ruff-pre-commit@v0.0.278...v0.0.280)
- [github.com/hadialqattan/pycln: v2.1.5 → v2.1.6](hadialqattan/pycln@v2.1.5...v2.1.6)

* style: pre-commit fixes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] authored Jul 25, 2023
1 parent e67d47e commit 15a7a1e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ repos:
- id: end-of-file-fixer

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.0.278"
rev: "v0.0.280"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]
Expand Down Expand Up @@ -59,7 +59,7 @@ repos:
- id: rst-inline-touching-normal

- repo: https://github.com/hadialqattan/pycln
rev: "v2.1.5"
rev: "v2.1.6"
hooks:
- id: pycln
args: [--all]
Expand Down
10 changes: 5 additions & 5 deletions src/decaylanguage/decay/decay.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def _build_decay_modes(
{'anti-D0': <DecayMode: daughters=K+ pi-, BF=1.0>,
'anti-D*0': <DecayMode: daughters=anti-D0 pi0, BF=0.619>}
"""
mother = list(dc_dict.keys())[0]
mother = next(iter(dc_dict.keys()))
dms = dc_dict[mother]

for dm in dms:
Expand All @@ -561,7 +561,7 @@ def _build_decay_modes(
if isinstance(ifs, dict):
# Replace the element with the key and
# store the present decay mode ignoring sub-decays
fs_local[i] = list(ifs.keys())[0]
fs_local[i] = next(iter(ifs.keys()))
# Recursively continue ...
_build_decay_modes(decay_modes, fs[i])
# Create the decay mode now that none of its particles
Expand Down Expand Up @@ -694,7 +694,7 @@ def _get_fs(decay: DecayModeDict) -> list[Any]:

# The mother particle is the first (and only) key of the dict
assert len(decay_chain.keys()) == 1
orig_mother = list(decay_chain.keys())[0]
orig_mother = next(iter(decay_chain.keys()))
mother = aliases.get(orig_mother, orig_mother) if aliases else orig_mother

for mode in _get_modes(decay_chain):
Expand Down Expand Up @@ -786,7 +786,7 @@ def from_dict(
raise RuntimeError("Input not in the expected format!") from e

decay_modes: dict[str, DecayMode] = {}
mother = list(decay_chain_dict.keys())[0]
mother = next(iter(decay_chain_dict.keys()))
_build_decay_modes(decay_modes, decay_chain_dict)

return cls(mother, decay_modes)
Expand Down Expand Up @@ -899,7 +899,7 @@ def _print(
link: bool = False,
last: bool = False,
) -> None:
mother = list(decay_dict.keys())[0]
mother = next(iter(decay_dict.keys()))
prefix = bar if (link and depth > 1) else ""
prefix = prefix + " " * indent * (depth - 1)
for i_decay in decay_dict[mother]:
Expand Down
6 changes: 3 additions & 3 deletions src/decaylanguage/decay/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def new_node_no_subchain(list_parts: list[str]) -> str:

def new_node_with_subchain(list_parts: list[Any]) -> str:
_list_parts = [
list(p.keys())[0] if isinstance(p, dict) else p for p in list_parts
next(iter(p.keys())) if isinstance(p, dict) else p for p in list_parts
]
label = html_table_label(_list_parts, add_tags=True)
r = f"dec{next(counter)}"
Expand Down Expand Up @@ -169,13 +169,13 @@ def iterate_chain(
)
for i, _p in enumerate(_list_parts): # type: ignore[arg-type]
if not isinstance(_p, str):
_k = list(_p.keys())[0]
_k = next(iter(_p.keys()))
iterate_chain(_p[_k], top_node=_ref_1, link_pos=i)

def has_subdecay(ds: list[Any]) -> bool:
return not all(isinstance(p, str) for p in ds)

k = list(self._chain.keys())[0]
k = next(iter(self._chain.keys()))
label = html_table_label([k], add_tags=True, bgcolor="#568dba")
sc = self._chain[k]

Expand Down
12 changes: 6 additions & 6 deletions tests/dec/test_dec.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def test_Lark_ModelNameCleanup_Transformer_no_params():
)

cleaned_tree = ModelNameCleanup().transform(t)
tree_decayline = list(cleaned_tree.find_data("decayline"))[0]
tree_decayline = next(iter(cleaned_tree.find_data("decayline")))
assert get_model_name(tree_decayline) == "PHSP"


Expand Down Expand Up @@ -701,7 +701,7 @@ def test_Lark_ModelNameCleanup_Transformer_with_params():
)

cleaned_tree = ModelNameCleanup().transform(t)
tree_decayline = list(cleaned_tree.find_data("decayline"))[0]
tree_decayline = next(iter(cleaned_tree.find_data("decayline")))
assert get_model_name(tree_decayline) == "SVV_HELAMP"
assert get_model_parameters(tree_decayline) == [
"0.0",
Expand Down Expand Up @@ -752,7 +752,7 @@ def test_Lark_DecayModelAliasReplacement_Transformer():
model_alias_defs=dict_model_aliases
).transform(t)

tree_decayline = list(unaliased_tree.find_data("decayline"))[0]
tree_decayline = next(iter(unaliased_tree.find_data("decayline")))
assert get_model_name(tree_decayline) == "SLBKPOLE"
assert get_model_parameters(tree_decayline) == ["1.0", "0.303", "1.0", "2.112"]

Expand All @@ -777,7 +777,7 @@ def test_Lark_DecayModelParamValueReplacement_Visitor_no_params():
DecayModelParamValueReplacement().visit(t)

# The visitor should do nothing in this case
tree_decayline = list(t.find_data("decayline"))[0]
tree_decayline = next(iter(t.find_data("decayline")))
assert get_model_name(tree_decayline) == "PHSP"
assert get_model_parameters(tree_decayline) == ""

Expand Down Expand Up @@ -809,7 +809,7 @@ def test_Lark_DecayModelParamValueReplacement_Visitor_single_value():

# Nothing done since model parameter name has no corresponding
# 'Define' statement from which the actual value can be inferred
tree_decayline = list(t.find_data("decayline"))[0]
tree_decayline = next(iter(t.find_data("decayline")))
assert get_model_name(tree_decayline) == "VSS_BMIX"
assert get_model_parameters(tree_decayline) == ["dm"]

Expand Down Expand Up @@ -858,7 +858,7 @@ def test_Lark_DecayModelParamValueReplacement_Visitor_list():
DecayModelParamValueReplacement().visit(t)

# The visitor should do nothing in this case
tree_decayline = list(t.find_data("decayline"))[0]
tree_decayline = next(iter(t.find_data("decayline")))
assert get_model_name(tree_decayline) == "SVV_HELAMP"
assert get_model_parameters(tree_decayline) == [0.0, 0.0, 0.0, 0.0, 1.0, 0.0]

Expand Down

0 comments on commit 15a7a1e

Please sign in to comment.