Skip to content

Commit

Permalink
refactor: Fix clang-tidy warnings in PyDeserializer. (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinZhihao-723 authored Jan 7, 2025
1 parent ea07551 commit 9157dfa
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions lint-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ tasks:
- "{{.CLP_FFI_PY_CPP_SRC_DIR}}/api_decoration.hpp"
- "{{.CLP_FFI_PY_CPP_SRC_DIR}}/error_messages.hpp"
- "{{.CLP_FFI_PY_CPP_SRC_DIR}}/ExceptionFFI.hpp"
- "{{.CLP_FFI_PY_CPP_SRC_DIR}}/ir/native/PyDeserializer.cpp"
- "{{.CLP_FFI_PY_CPP_SRC_DIR}}/ir/native/PyDeserializer.hpp"
- "{{.CLP_FFI_PY_CPP_SRC_DIR}}/ir/native/PyKeyValuePairLogEvent.cpp"
- "{{.CLP_FFI_PY_CPP_SRC_DIR}}/ir/native/PyKeyValuePairLogEvent.hpp"
- "{{.CLP_FFI_PY_CPP_SRC_DIR}}/ir/native/PySerializer.cpp"
Expand Down
14 changes: 9 additions & 5 deletions src/clp_ffi_py/ir/native/PyDeserializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ CLP_FFI_PY_METHOD auto PyDeserializer_deserialize_log_event(PyDeserializer* self
*/
CLP_FFI_PY_METHOD auto PyDeserializer_dealloc(PyDeserializer* self) -> void;

// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays)
// NOLINTNEXTLINE(*-avoid-c-arrays, cppcoreguidelines-avoid-non-const-global-variables)
PyMethodDef PyDeserializer_method_table[]{
{"deserialize_log_event",
py_c_function_cast(PyDeserializer_deserialize_log_event),
Expand All @@ -82,7 +82,8 @@ PyMethodDef PyDeserializer_method_table[]{
{nullptr}
};

// NOLINTBEGIN(cppcoreguidelines-avoid-c-arrays, cppcoreguidelines-pro-type-*-cast)
// NOLINTBEGIN(cppcoreguidelines-pro-type-*-cast)
// NOLINTNEXTLINE(*-avoid-c-arrays, cppcoreguidelines-avoid-non-const-global-variables)
PyType_Slot PyDeserializer_slots[]{
{Py_tp_alloc, reinterpret_cast<void*>(PyType_GenericAlloc)},
{Py_tp_dealloc, reinterpret_cast<void*>(PyDeserializer_dealloc)},
Expand All @@ -92,11 +93,12 @@ PyType_Slot PyDeserializer_slots[]{
{Py_tp_doc, const_cast<void*>(static_cast<void const*>(cPyDeserializerDoc))},
{0, nullptr}
};
// NOLINTEND(cppcoreguidelines-avoid-c-arrays, cppcoreguidelines-pro-type-*-cast)
// NOLINTEND(cppcoreguidelines-pro-type-*-cast)

/**
* `PyDeserializer`'s Python type specifications.
*/
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
PyType_Spec PyDeserializer_type_spec{
"clp_ffi_py.ir.native.Deserializer",
sizeof(PyDeserializer),
Expand Down Expand Up @@ -197,7 +199,7 @@ auto PyDeserializer::init(
if (deserializer_result.has_error()) {
PyErr_Format(
PyExc_RuntimeError,
cDeserializerCreateErrorFormatStr.data(),
get_c_str_from_constexpr_string_view(cDeserializerCreateErrorFormatStr),
deserializer_result.error().message().c_str()
);
return false;
Expand Down Expand Up @@ -232,7 +234,9 @@ auto PyDeserializer::deserialize_log_event() -> PyObject* {
if (std::errc::result_out_of_range != err) {
PyErr_Format(
PyExc_RuntimeError,
cDeserializerDeserializeNextIrUnitErrorFormatStr.data(),
get_c_str_from_constexpr_string_view(
cDeserializerDeserializeNextIrUnitErrorFormatStr
),
err.message().c_str()
);
return nullptr;
Expand Down
1 change: 0 additions & 1 deletion src/clp_ffi_py/ir/native/PyDeserializer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <wrapped_facade_headers/Python.hpp> // Must be included before any other header files

#include <functional>
#include <system_error>
#include <utility>

#include <clp/ffi/ir_stream/decoding_methods.hpp>
Expand Down

0 comments on commit 9157dfa

Please sign in to comment.