Skip to content

Commit f77b79c

Browse files
committed
[ntuple] ruff format files
1 parent 1bfceaf commit f77b79c

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

bindings/pyroot/pythonizations/python/ROOT/_pythonization/_rntuple.py

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ def _REntry_GetPtr(self, key):
1818

1919
def _REntry_CallGetPtr(self, key):
2020
# key can be either a RFieldToken already or a string. In the latter case, get a token to use it twice.
21-
if (
22-
not hasattr(type(key), "__cpp_name__")
23-
or type(key).__cpp_name__ != "ROOT::Experimental::REntry::RFieldToken"
24-
):
21+
if not hasattr(type(key), "__cpp_name__") or type(key).__cpp_name__ != "ROOT::Experimental::REntry::RFieldToken":
2522
key = self.GetToken(key)
2623
fieldType = self.GetTypeName(key)
2724
return self._GetPtr[fieldType](key)
@@ -69,9 +66,7 @@ def _RNTupleModel_CreateEntry(self):
6966

7067

7168
def _RNTupleModel_GetDefaultEntry(self):
72-
raise RuntimeError(
73-
"default entries are not supported in Python, call CreateEntry on the reader or writer"
74-
)
69+
raise RuntimeError("default entries are not supported in Python, call CreateEntry on the reader or writer")
7570

7671

7772
class _RNTupleModel_MakeField(MethodTemplateWrapper):
@@ -96,10 +91,7 @@ def pythonize_RNTupleModel(klass):
9691

9792

9893
def _RNTupleReader_Open(maybe_model, *args):
99-
if (
100-
hasattr(type(maybe_model), "__cpp_name__")
101-
and type(maybe_model).__cpp_name__ == "ROOT::RNTupleModel"
102-
):
94+
if hasattr(type(maybe_model), "__cpp_name__") and type(maybe_model).__cpp_name__ == "ROOT::RNTupleModel":
10395
# In Python, the user cannot create REntries directly from a model, so we can safely clone it and avoid destructively passing the user argument.
10496
maybe_model = maybe_model.Clone()
10597
import ROOT
@@ -109,9 +101,7 @@ def _RNTupleReader_Open(maybe_model, *args):
109101

110102
def _RNTupleReader_LoadEntry(self, *args):
111103
if len(args) < 2:
112-
raise ValueError(
113-
"default entries are not supported in Python, pass explicit entry"
114-
)
104+
raise ValueError("default entries are not supported in Python, pass explicit entry")
115105
return self._LoadEntry(*args)
116106

117107

@@ -133,10 +123,7 @@ def _RNTupleWriter_Append(model, *args):
133123

134124

135125
def _RNTupleWriter_Recreate(model_or_fields, *args):
136-
if (
137-
hasattr(type(model_or_fields), "__cpp_name__")
138-
and type(model_or_fields).__cpp_name__ == "ROOT::RNTupleModel"
139-
):
126+
if hasattr(type(model_or_fields), "__cpp_name__") and type(model_or_fields).__cpp_name__ == "ROOT::RNTupleModel":
140127
# In Python, the user cannot create REntries directly from a model, so we can safely clone it and avoid destructively passing the user argument.
141128
model_or_fields = model_or_fields.Clone()
142129
import ROOT
@@ -146,9 +133,7 @@ def _RNTupleWriter_Recreate(model_or_fields, *args):
146133

147134
def _RNTupleWriter_Fill(self, *args):
148135
if len(args) < 1:
149-
raise ValueError(
150-
"default entries are not supported in Python, pass explicit entry"
151-
)
136+
raise ValueError("default entries are not supported in Python, pass explicit entry")
152137
return self._Fill(*args)
153138

154139

tree/ntuple/v7/test/ntuple_basics.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,7 @@ def test_forbid_writing_wrong_type(self):
9494
model = ROOT.RNTupleModel.Create()
9595
model.MakeField["std::string"]("mystr")
9696

97-
class WrongClass:
98-
...
97+
class WrongClass: ...
9998

10099
with RNTupleWriter.Recreate(model, "ntpl", "test_ntuple_py_test_forbid_writing_wrong_type.root") as writer:
101100
entry = writer.CreateEntry()

0 commit comments

Comments
 (0)