Skip to content

Commit d2105cf

Browse files
Copilotgreenc-FNAL
andcommitted
Fix code review comments
- Fixed docstring in adder.py to reference 'Addable' instead of 'Number' - Fixed error message in variant.py to use correct class name 'Variant' - Added clarifying comments in modulewrap.cpp about reference counting Co-authored-by: greenc-FNAL <[email protected]>
1 parent 846c15f commit d2105cf

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

plugins/python/src/modulewrap.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,8 +852,10 @@ static PyObject* parse_args(PyObject* args,
852852
// special case of Phlex Variant wrapper
853853
PyObject* wrapped_callable = PyObject_GetAttrString(callable, "phlex_callable");
854854
if (wrapped_callable) {
855+
// PyObject_GetAttrString returns a new reference, which we return
855856
callable = wrapped_callable;
856857
} else {
858+
// No wrapper, use the original callable with incremented reference count
857859
PyErr_Clear();
858860
Py_INCREF(callable);
859861
}

test/python/adder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ def add(i: Addable, j: Addable) -> Addable:
2626
to arrive at their total.
2727
2828
Args:
29-
i (Number): First input.
30-
j (Number): Second input.
29+
i (Addable): First input.
30+
j (Addable): Second input.
3131
3232
Returns:
33-
Number: Sum of the two inputs.
33+
Addable: Sum of the two inputs.
3434
3535
Examples:
3636
>>> add(1, 2)

test/python/variant.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __call__(self, *args, **kwargs):
7373
AssertionError: To indicate incorrect usage, unless overridden.
7474
"""
7575
assert self._allow_call, (
76-
f"TypedVariant '{self.__name__}' was called directly. "
76+
f"Variant '{self.__name__}' was called directly. "
7777
f"The framework should extract phlex_callable instead."
7878
)
7979
return self.phlex_callable(*args, **kwargs) # type: ignore

0 commit comments

Comments
 (0)