From 7505b361da4b0c15b96c25526bffb81bcecdd720 Mon Sep 17 00:00:00 2001 From: Richard Waite Date: Wed, 29 Jan 2025 11:58:17 +0000 Subject: [PATCH 1/7] Cppcheck suppressions set 56 --- .../mantid/api/src/Exports/AlgorithmManager.cpp | 2 ++ .../mantid/api/src/Exports/AlgorithmProperty.cpp | 2 +- Framework/PythonInterface/mantid/api/src/Exports/Axis.cpp | 1 + .../mantid/api/src/Exports/ExperimentInfo.cpp | 1 + .../PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp | 7 +++---- .../PythonInterface/mantid/api/src/Exports/IEventList.cpp | 8 ++++---- .../PythonInterface/mantid/api/src/Exports/IFunction.cpp | 1 + .../mantid/api/src/Exports/IFunction1D.cpp | 2 ++ .../mantid/api/src/Exports/IMaskWorkspace.cpp | 3 ++- .../mantid/api/src/Exports/IPeakFunction.cpp | 3 ++- 10 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp index ca5c4f916097..8c05f5f81789 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp @@ -124,8 +124,10 @@ GNU_DIAG_OFF("unused-local-typedef") // Seen with GCC 7.1.1 and Boost 1.63.0 GNU_DIAG_OFF("conversion") /// Define overload generators +// cppcheck-suppress-begin unknownMacro BOOST_PYTHON_FUNCTION_OVERLOADS(create_overloads, create, 2, 3) BOOST_PYTHON_FUNCTION_OVERLOADS(createUnmanaged_overloads, createUnmanaged, 2, 3) +// cppcheck-suppress-end unknownMacro GNU_DIAG_ON("conversion") GNU_DIAG_ON("unused-local-typedef") ///@endcond diff --git a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp index b386d8151b84..64461f6480e8 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp @@ -27,7 +27,7 @@ namespace { * @param direction An output/input/inout property * @return A pointer to a new AlgorithmProperty object */ -AlgorithmProperty *createPropertyWithValidatorAndDirection(const std::string &name, IValidator *validator, +AlgorithmProperty *createPropertyWithValidatorAndDirection(const std::string &name, const IValidator *validator, unsigned int direction) { return new AlgorithmProperty(name, validator->clone(), direction); } diff --git a/Framework/PythonInterface/mantid/api/src/Exports/Axis.cpp b/Framework/PythonInterface/mantid/api/src/Exports/Axis.cpp index c14f3028de25..b79d55155993 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/Axis.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/Axis.cpp @@ -41,6 +41,7 @@ GNU_DIAG_OFF("unused-local-typedef") GNU_DIAG_OFF("conversion") // Overloads for operator() function which has 1 optional argument +// cppcheck-suppress unknownMacro BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(Axis_getValue, Axis::getValue, 1, 2) GNU_DIAG_ON("conversion") diff --git a/Framework/PythonInterface/mantid/api/src/Exports/ExperimentInfo.cpp b/Framework/PythonInterface/mantid/api/src/Exports/ExperimentInfo.cpp index ea5b7fc79e78..0a7750bdf82e 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/ExperimentInfo.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/ExperimentInfo.cpp @@ -54,6 +54,7 @@ GNU_DIAG_OFF("unused-local-typedef") // Seen with GCC 7.1.1 and Boost 1.63.0 GNU_DIAG_OFF("conversion") /// Overload generator for getInstrumentFilename +// cppcheck-suppress unknownMacro BOOST_PYTHON_FUNCTION_OVERLOADS(getInstrumentFilename_Overload, getInstrumentFilenameWarn, 1, 2) GNU_DIAG_ON("conversion") GNU_DIAG_ON("unused-local-typedef") diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp index d4d52209d692..91f647164102 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp @@ -221,7 +221,7 @@ std::string createDocString(const IAlgorithm &self) { buffer << "Property descriptions: " << EOL << EOL; // write the actual property descriptions for (size_t i = 0; i < numProps; ++i) { - Mantid::Kernel::Property *prop = properties[i]; + const Mantid::Kernel::Property *prop = properties[i]; buffer << prop->name() << "(" << Mantid::Kernel::Direction::asText(prop->direction()); if (!prop->isValid().empty()) buffer << ":req"; @@ -251,7 +251,7 @@ std::string createDocString(const IAlgorithm &self) { struct AllowCThreads { explicit AllowCThreads(const object &algm) : m_tracefunc(nullptr), m_tracearg(nullptr), m_saved(nullptr), m_tracking(false) { - PyThreadState *curThreadState = PyThreadState_GET(); + const PyThreadState *curThreadState = PyThreadState_GET(); m_tracefunc = curThreadState->c_tracefunc; m_tracearg = curThreadState->c_traceobj; Py_XINCREF(m_tracearg); @@ -315,8 +315,7 @@ PyObject *getAlgorithmID(const IAlgorithm &self) { AlgorithmID id = self.getAlgorithmID(); if (id) return to_python_value()(AlgorithmIDProxy(id)); - else - Py_RETURN_NONE; + Py_RETURN_NONE; } //-------------------------------------------------------------------------------------- diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IEventList.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IEventList.cpp index c572110c4252..31e4aa2ba1cd 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IEventList.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IEventList.cpp @@ -72,12 +72,12 @@ void export_IEventList() { "Mask out events that have a tof between tofMin and tofMax " "(inclusively)") .def("maskCondition", &maskCondition, args("self", "mask"), "Mask out events by the condition vector") - .def("getTofs", (std::vector(IEventList::*)(void) const) & IEventList::getTofs, args("self"), + .def("getTofs", (std::vector(IEventList::*)() const) & IEventList::getTofs, args("self"), return_clone_numpy(), "Get a vector of the TOFs of the events") - .def("getWeights", (std::vector(IEventList::*)(void) const) & IEventList::getWeights, args("self"), + .def("getWeights", (std::vector(IEventList::*)() const) & IEventList::getWeights, args("self"), + return_clone_numpy(), "Get a vector of the weights of the events") + .def("getWeightErrors", (std::vector(IEventList::*)() const) & IEventList::getWeightErrors, args("self"), return_clone_numpy(), "Get a vector of the weights of the events") - .def("getWeightErrors", (std::vector(IEventList::*)(void) const) & IEventList::getWeightErrors, - args("self"), return_clone_numpy(), "Get a vector of the weights of the events") .def("getPulseTimes", &IEventList::getPulseTimes, args("self"), "Get a vector of the pulse times of the events") .def("getPulseTimesAsNumpy", make_function(&IEventList::getPulseTimes, return_value_policy()), diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IFunction.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IFunction.cpp index 6dfe52c6be17..a1ac0cae973d 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IFunction.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IFunction.cpp @@ -147,6 +147,7 @@ BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(declareAttributeType1_Overloads, declareA using declareAttributeType2 = void (IFunctionAdapter::*)(const std::string &name, const boost::python::object &defaultValue, const boost::python::object &validator); +// cppcheck-suppress unknownMacro BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(declareAttributeType2_Overloads, declareAttribute, 3, 3) BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(tie_Overloads, tie, 2, 3) diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp index 244612b417a2..62b0be2b68f2 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp @@ -18,6 +18,8 @@ void export_IFunction1D() { * The Python held type, std::shared_ptr, allows * the class' virtual functions to be overridden in Python */ + // suppress c-style cast of Function1D object - think this is desired behaviour + // cppcheck-suppress cstyleCast class_, std::shared_ptr, boost::noncopyable>( "IFunction1D", "Base class for 1D Fit functions") .def("function1D", (object(IFunction1DAdapter::*)(const object &) const)&IFunction1DAdapter::function1D, diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IMaskWorkspace.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IMaskWorkspace.cpp index 2381f526603c..f631decdc603 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IMaskWorkspace.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IMaskWorkspace.cpp @@ -41,6 +41,7 @@ void export_IMaskWorkspace() { .def("isMasked", isMaskedFromList, (arg("self"), arg("detector_id_list")), "Returns whether all of the given detector ID list are masked"); - // register pointers + // register pointers - required to map between C++ type T and python type + // cppcheck-suppress unusedScopedObject RegisterWorkspacePtrToPython(); } diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp index 81dc15df0da8..100a9fc2fd1e 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp @@ -17,7 +17,8 @@ using namespace boost::python; void export_IPeakFunction() { register_ptr_to_python>(); - + // suppress c-style cast of IPakFunction object - think this is desired behaviour + // cppcheck-suppress cstyleCast class_, std::shared_ptr, boost::noncopyable>( "IPeakFunction", "Base class for peak Fit functions") .def("functionLocal", (object(IPeakFunctionAdapter::*)(const object &) const)&IPeakFunctionAdapter::functionLocal, From 676caa38fc9bd5d13c14b4b0f4a501b64b24f1ff Mon Sep 17 00:00:00 2001 From: Richard Waite Date: Wed, 29 Jan 2025 14:32:29 +0000 Subject: [PATCH 2/7] Remove lines from suppressions and other fixes Py_RETURN_NONE renamed to Py_NONE and return removed (now to be done manually) as not used anywhere else and was confusing cppcheck with missing return. Had to make lambda function wrapper if wanted to return const pointer in AlgorithmProperty.cpp Co-authored-by: Mohamed Almaki --- .../mantid/api/src/Exports/AlgorithmManager.cpp | 4 ++-- .../mantid/api/src/Exports/AlgorithmProperty.cpp | 8 +++++--- .../mantid/api/src/Exports/IAlgorithm.cpp | 2 +- .../mantid/api/src/Exports/IFunction1D.cpp | 4 ++-- .../mantid/api/src/Exports/IPeakFunction.cpp | 4 ++-- buildconfig/CMake/CppCheck_Suppressions.txt.in | 9 --------- 6 files changed, 12 insertions(+), 19 deletions(-) diff --git a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp index 8c05f5f81789..ad6c7bea3007 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp @@ -124,10 +124,10 @@ GNU_DIAG_OFF("unused-local-typedef") // Seen with GCC 7.1.1 and Boost 1.63.0 GNU_DIAG_OFF("conversion") /// Define overload generators -// cppcheck-suppress-begin unknownMacro +// cppcheck-suppress unknownMacro BOOST_PYTHON_FUNCTION_OVERLOADS(create_overloads, create, 2, 3) BOOST_PYTHON_FUNCTION_OVERLOADS(createUnmanaged_overloads, createUnmanaged, 2, 3) -// cppcheck-suppress-end unknownMacro + GNU_DIAG_ON("conversion") GNU_DIAG_ON("unused-local-typedef") ///@endcond diff --git a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp index 64461f6480e8..62104f431967 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp @@ -39,9 +39,11 @@ AlgorithmProperty *createPropertyWithValidatorAndDirection(const std::string &na * when passed to the framework * @return A pointer to a new AlgorithmProperty object */ -AlgorithmProperty *createPropertyWithValidator(const std::string &name, IValidator *validator) { - return createPropertyWithValidatorAndDirection(name, validator, Mantid::Kernel::Direction::Input); -} +const std::function createPropertyWithValidator = + [](const std::string &name, const IValidator *validator) { + return createPropertyWithValidatorAndDirection(name, validator, Mantid::Kernel::Direction::Input); + }; + } // namespace void export_AlgorithmProperty() { diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp index 91f647164102..6a02577fd08d 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp @@ -315,7 +315,7 @@ PyObject *getAlgorithmID(const IAlgorithm &self) { AlgorithmID id = self.getAlgorithmID(); if (id) return to_python_value()(AlgorithmIDProxy(id)); - Py_RETURN_NONE; + return Py_NONE; } //-------------------------------------------------------------------------------------- diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp index 62b0be2b68f2..75fb3fc0926c 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp @@ -18,10 +18,10 @@ void export_IFunction1D() { * The Python held type, std::shared_ptr, allows * the class' virtual functions to be overridden in Python */ - // suppress c-style cast of Function1D object - think this is desired behaviour - // cppcheck-suppress cstyleCast class_, std::shared_ptr, boost::noncopyable>( "IFunction1D", "Base class for 1D Fit functions") + // suppress c-style cast of Function1D object - think this is desired behaviour + // cppcheck-suppress cstyleCast .def("function1D", (object(IFunction1DAdapter::*)(const object &) const)&IFunction1DAdapter::function1D, (arg("self"), arg("xvals")), "Calculate the values of the function for the given x values and " diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp index 100a9fc2fd1e..164f0bdff9c4 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp @@ -17,10 +17,10 @@ using namespace boost::python; void export_IPeakFunction() { register_ptr_to_python>(); - // suppress c-style cast of IPakFunction object - think this is desired behaviour - // cppcheck-suppress cstyleCast class_, std::shared_ptr, boost::noncopyable>( "IPeakFunction", "Base class for peak Fit functions") + // suppress c-style cast of IPeakFunction object - think this is desired behaviour + // cppcheck-suppress cstyleCast .def("functionLocal", (object(IPeakFunctionAdapter::*)(const object &) const)&IPeakFunctionAdapter::functionLocal, (arg("self"), arg("vec_x")), "Calculate the values of the function for the given x values. The " diff --git a/buildconfig/CMake/CppCheck_Suppressions.txt.in b/buildconfig/CMake/CppCheck_Suppressions.txt.in index 611db6b788de..14c0215edbfa 100644 --- a/buildconfig/CMake/CppCheck_Suppressions.txt.in +++ b/buildconfig/CMake/CppCheck_Suppressions.txt.in @@ -837,20 +837,11 @@ constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/sr unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/Algorithm.cpp:76 unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmFactory.cpp:155 unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmManager.cpp:127 -constParameterCallback:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp:30 unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/Axis.cpp:44 unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/ExperimentInfo.cpp:57 -constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp:224 -constVariablePointer:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp:254 -missingReturn:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp:319 -cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IEventList.cpp:75 -cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IEventList.cpp:77 -cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IEventList.cpp:79 unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IFunction.cpp:150 -cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp:23 cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IMDHistoWorkspace.cpp:50 unusedScopedObject:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IMaskWorkspace.cpp:45 -cstyleCast:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp:23 unusedScopedObject:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/ISplittersWorkspace.cpp:25 unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/ITableWorkspace.cpp:251 unknownMacro:${CMAKE_SOURCE_DIR}/Framework/PythonInterface/mantid/api/src/Exports/InstrumentFileFinder.cpp:36 From 0f31aafbd91aa992172add12bdbb4b3cc57a9a8b Mon Sep 17 00:00:00 2001 From: Richard Waite Date: Wed, 29 Jan 2025 15:33:27 +0000 Subject: [PATCH 3/7] Not use macro to return --- Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp index 6a02577fd08d..38532427278f 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp @@ -315,7 +315,7 @@ PyObject *getAlgorithmID(const IAlgorithm &self) { AlgorithmID id = self.getAlgorithmID(); if (id) return to_python_value()(AlgorithmIDProxy(id)); - return Py_NONE; + return Py_NewRef(Py_None) } //-------------------------------------------------------------------------------------- From 53c7a22a4c56557aaa86b44639fdd25b28979d24 Mon Sep 17 00:00:00 2001 From: Mohammed Almakki Date: Thu, 30 Jan 2025 18:25:19 +0000 Subject: [PATCH 4/7] Replace std::function pointer with a C style function pointer --- .../mantid/api/src/Exports/AlgorithmProperty.cpp | 11 +++++------ .../mantid/api/src/Exports/IAlgorithm.cpp | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp index 62104f431967..5eba265958d7 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/AlgorithmProperty.cpp @@ -39,11 +39,10 @@ AlgorithmProperty *createPropertyWithValidatorAndDirection(const std::string &na * when passed to the framework * @return A pointer to a new AlgorithmProperty object */ -const std::function createPropertyWithValidator = - [](const std::string &name, const IValidator *validator) { - return createPropertyWithValidatorAndDirection(name, validator, Mantid::Kernel::Direction::Input); - }; - +static const AlgorithmProperty *(*const createPropertyWithValidator)(const std::string &, const IValidator *) = + +[](const std::string &name, const IValidator *validator) -> const AlgorithmProperty * { + return createPropertyWithValidatorAndDirection(name, validator, Mantid::Kernel::Direction::Input); +}; } // namespace void export_AlgorithmProperty() { @@ -56,7 +55,7 @@ void export_AlgorithmProperty() { .def(init(args("name"))) // These variants require the validator object to be cloned .def("__init__", - make_constructor(&createPropertyWithValidator, default_call_policies(), args("name", "validator"))) + make_constructor(createPropertyWithValidator, default_call_policies(), args("name", "validator"))) .def("__init__", make_constructor(&createPropertyWithValidatorAndDirection, default_call_policies(), args("name", "validator", "direction"))); } diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp index 38532427278f..de382e450ec9 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp @@ -315,7 +315,7 @@ PyObject *getAlgorithmID(const IAlgorithm &self) { AlgorithmID id = self.getAlgorithmID(); if (id) return to_python_value()(AlgorithmIDProxy(id)); - return Py_NewRef(Py_None) + return Py_NewRef(Py_None); } //-------------------------------------------------------------------------------------- From 28b5656d4ec59e58a1330ccbbe3ae5fdc6646bd2 Mon Sep 17 00:00:00 2001 From: RichardWaiteSTFC <55979119+RichardWaiteSTFC@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:38:13 +0000 Subject: [PATCH 5/7] Update Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp Co-authored-by: Gui Maciel Pereira <80104863+GuiMacielPereira@users.noreply.github.com> --- .../PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp index 164f0bdff9c4..3b9409fe311a 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp @@ -19,9 +19,8 @@ void export_IPeakFunction() { register_ptr_to_python>(); class_, std::shared_ptr, boost::noncopyable>( "IPeakFunction", "Base class for peak Fit functions") - // suppress c-style cast of IPeakFunction object - think this is desired behaviour - // cppcheck-suppress cstyleCast - .def("functionLocal", (object(IPeakFunctionAdapter::*)(const object &) const)&IPeakFunctionAdapter::functionLocal, + // cppcheck-suppress cstyleCast - cppcheck complains but already using static_cast + .def("functionLocal", static_cast(&IPeakFunctionAdapter::functionLocal), (arg("self"), arg("vec_x")), "Calculate the values of the function for the given x values. The " "output should be stored in the out array") From 6208dc202eb6cd4fbfc17475a20d2ed0fae798e4 Mon Sep 17 00:00:00 2001 From: RichardWaiteSTFC <55979119+RichardWaiteSTFC@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:38:20 +0000 Subject: [PATCH 6/7] Update Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp Co-authored-by: Gui Maciel Pereira <80104863+GuiMacielPereira@users.noreply.github.com> --- .../PythonInterface/mantid/api/src/Exports/IFunction1D.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp index 75fb3fc0926c..5cff10ba01ce 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp @@ -20,9 +20,8 @@ void export_IFunction1D() { */ class_, std::shared_ptr, boost::noncopyable>( "IFunction1D", "Base class for 1D Fit functions") - // suppress c-style cast of Function1D object - think this is desired behaviour - // cppcheck-suppress cstyleCast - .def("function1D", (object(IFunction1DAdapter::*)(const object &) const)&IFunction1DAdapter::function1D, + // cppcheck-suppress cstyleCast - cppcheck complains but already using static_cast + .def("function1D", static_cast(&IFunction1DAdapter::function1D), (arg("self"), arg("xvals")), "Calculate the values of the function for the given x values and " "returns them"); From 853b6879e09272f5587c0fcfaba8a94499fe9176 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:40:47 +0000 Subject: [PATCH 7/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../PythonInterface/mantid/api/src/Exports/IFunction1D.cpp | 3 ++- .../PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp index 5cff10ba01ce..a0dbb25e29ff 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IFunction1D.cpp @@ -21,7 +21,8 @@ void export_IFunction1D() { class_, std::shared_ptr, boost::noncopyable>( "IFunction1D", "Base class for 1D Fit functions") // cppcheck-suppress cstyleCast - cppcheck complains but already using static_cast - .def("function1D", static_cast(&IFunction1DAdapter::function1D), + .def("function1D", + static_cast(&IFunction1DAdapter::function1D), (arg("self"), arg("xvals")), "Calculate the values of the function for the given x values and " "returns them"); diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp index 3b9409fe311a..c2be215f445b 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IPeakFunction.cpp @@ -20,7 +20,8 @@ void export_IPeakFunction() { class_, std::shared_ptr, boost::noncopyable>( "IPeakFunction", "Base class for peak Fit functions") // cppcheck-suppress cstyleCast - cppcheck complains but already using static_cast - .def("functionLocal", static_cast(&IPeakFunctionAdapter::functionLocal), + .def("functionLocal", + static_cast(&IPeakFunctionAdapter::functionLocal), (arg("self"), arg("vec_x")), "Calculate the values of the function for the given x values. The " "output should be stored in the out array")