Skip to content

Commit fa8baab

Browse files
committed
Fix clang-tidy issues
1 parent 69a1914 commit fa8baab

File tree

8 files changed

+36
-27
lines changed

8 files changed

+36
-27
lines changed

hal/src/main/python/hal/simulation/sim_cb.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22
#pragma once
33

4+
#include <cstdint>
5+
#include <functional>
6+
47
class SimCB {
58
public:
69
SimCB(std::function<void(void)> fn, std::function<void(int32_t)> cancel)

ntcore/src/main/python/ntcore/src/nt_type_caster.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
#include <pybind11/pybind11.h>
66

7-
namespace pybind11 {
8-
namespace detail {
7+
namespace pybind11::detail {
98

109
// ntcore uses std::vector<uint8_t> anytime there is a raw value, so
1110
// add this specialization to convert to/from bytes directly
@@ -39,5 +38,4 @@ struct type_caster<std::vector<uint8_t>> {
3938
}
4039
};
4140

42-
} // namespace detail
43-
} // namespace pybind11
41+
} // namespace pybind11::detail

ntcore/src/main/python/ntcore/src/pyentry.cpp

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ py::object GetBooleanEntry(const wpi::nt::NetworkTableEntry& entry,
1818
py::gil_scoped_release release;
1919
value = wpi::nt::GetEntryValue(entry.GetHandle());
2020
}
21-
if (!value || value.type() != NT_BOOLEAN)
21+
if (!value || value.type() != NT_BOOLEAN) {
2222
return defaultValue;
23+
}
2324
return py::cast(value.GetBoolean());
2425
}
2526

@@ -30,8 +31,9 @@ py::object GetDoubleEntry(const wpi::nt::NetworkTableEntry& entry,
3031
py::gil_scoped_release release;
3132
value = wpi::nt::GetEntryValue(entry.GetHandle());
3233
}
33-
if (!value || value.type() != NT_DOUBLE)
34+
if (!value || value.type() != NT_DOUBLE) {
3435
return defaultValue;
36+
}
3537
return py::cast(value.GetDouble());
3638
}
3739

@@ -42,8 +44,9 @@ py::object GetFloatEntry(const wpi::nt::NetworkTableEntry& entry,
4244
py::gil_scoped_release release;
4345
value = wpi::nt::GetEntryValue(entry.GetHandle());
4446
}
45-
if (!value || value.type() != NT_FLOAT)
47+
if (!value || value.type() != NT_FLOAT) {
4648
return defaultValue;
49+
}
4750
return py::cast(value.GetFloat());
4851
}
4952

@@ -54,8 +57,9 @@ py::object GetIntegerEntry(const wpi::nt::NetworkTableEntry& entry,
5457
py::gil_scoped_release release;
5558
value = wpi::nt::GetEntryValue(entry.GetHandle());
5659
}
57-
if (!value || value.type() != NT_INTEGER)
60+
if (!value || value.type() != NT_INTEGER) {
5861
return defaultValue;
62+
}
5963
return py::cast(value.GetInteger());
6064
}
6165

@@ -66,8 +70,9 @@ py::object GetStringEntry(const wpi::nt::NetworkTableEntry& entry,
6670
py::gil_scoped_release release;
6771
value = wpi::nt::GetEntryValue(entry.GetHandle());
6872
}
69-
if (!value || value.type() != NT_STRING)
73+
if (!value || value.type() != NT_STRING) {
7074
return defaultValue;
75+
}
7176
auto s = value.GetString();
7277
return py::str(s.data(), s.size());
7378
}
@@ -79,8 +84,9 @@ py::object GetRawEntry(const wpi::nt::NetworkTableEntry& entry,
7984
py::gil_scoped_release release;
8085
value = wpi::nt::GetEntryValue(entry.GetHandle());
8186
}
82-
if (!value || value.type() != NT_RAW)
87+
if (!value || value.type() != NT_RAW) {
8388
return defaultValue;
89+
}
8490
return py::cast(value.GetRaw());
8591
}
8692

@@ -91,8 +97,9 @@ py::object GetBooleanArrayEntry(const wpi::nt::NetworkTableEntry& entry,
9197
py::gil_scoped_release release;
9298
value = wpi::nt::GetEntryValue(entry.GetHandle());
9399
}
94-
if (!value || value.type() != NT_BOOLEAN_ARRAY)
100+
if (!value || value.type() != NT_BOOLEAN_ARRAY) {
95101
return defaultValue;
102+
}
96103
// ntcore will return bit vector by default. Convert to List[bool]
97104
auto v = value.value();
98105
py::list l(v.data.arr_boolean.size);
@@ -110,8 +117,9 @@ py::object GetDoubleArrayEntry(const wpi::nt::NetworkTableEntry& entry,
110117
py::gil_scoped_release release;
111118
value = wpi::nt::GetEntryValue(entry.GetHandle());
112119
}
113-
if (!value || value.type() != NT_DOUBLE_ARRAY)
120+
if (!value || value.type() != NT_DOUBLE_ARRAY) {
114121
return defaultValue;
122+
}
115123
return py::cast(value.GetDoubleArray());
116124
}
117125

@@ -122,8 +130,9 @@ py::object GetFloatArrayEntry(const wpi::nt::NetworkTableEntry& entry,
122130
py::gil_scoped_release release;
123131
value = wpi::nt::GetEntryValue(entry.GetHandle());
124132
}
125-
if (!value || value.type() != NT_FLOAT_ARRAY)
133+
if (!value || value.type() != NT_FLOAT_ARRAY) {
126134
return defaultValue;
135+
}
127136
return py::cast(value.GetFloatArray());
128137
}
129138

@@ -134,8 +143,9 @@ py::object GetIntegerArrayEntry(const wpi::nt::NetworkTableEntry& entry,
134143
py::gil_scoped_release release;
135144
value = wpi::nt::GetEntryValue(entry.GetHandle());
136145
}
137-
if (!value || value.type() != NT_INTEGER_ARRAY)
146+
if (!value || value.type() != NT_INTEGER_ARRAY) {
138147
return defaultValue;
148+
}
139149
return py::cast(value.GetIntegerArray());
140150
}
141151

@@ -146,8 +156,9 @@ py::object GetStringArrayEntry(const wpi::nt::NetworkTableEntry& entry,
146156
py::gil_scoped_release release;
147157
value = wpi::nt::GetEntryValue(entry.GetHandle());
148158
}
149-
if (!value || value.type() != NT_STRING_ARRAY)
159+
if (!value || value.type() != NT_STRING_ARRAY) {
150160
return defaultValue;
161+
}
151162
std::span<const std::string> rval = value.GetStringArray();
152163
return py::cast(rval);
153164
}
@@ -159,8 +170,9 @@ py::object GetValueEntry(const wpi::nt::NetworkTableEntry& entry,
159170
py::gil_scoped_release release;
160171
value = wpi::nt::GetEntryValue(entry.GetHandle());
161172
}
162-
if (!value)
173+
if (!value) {
163174
return defaultValue;
175+
}
164176
return ntvalue2py(value);
165177
}
166178

wpilibc/src/main/python/wpilib/src/rpy/MotorControllerGroup.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class PyMotorControllerGroup
1919
public MotorController,
2020
public wpi::util::SendableHelper<PyMotorControllerGroup> {
2121
public:
22-
PyMotorControllerGroup(
22+
explicit PyMotorControllerGroup(
2323
std::vector<std::shared_ptr<wpi::MotorController>>&& args)
2424
: m_motorControllers(args) {}
2525
~PyMotorControllerGroup() override = default;

wpimath/src/main/python/wpimath/_impl/src/PyTrajectoryConstraint.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ struct PyTrajectoryConstraint : public TrajectoryConstraint {
2929

3030
}; // namespace wpi::math
3131

32-
namespace pybind11 {
33-
namespace detail {
32+
namespace pybind11::detail {
3433

3534
template <>
3635
struct type_caster<wpi::math::PyTrajectoryConstraint> {
@@ -59,5 +58,4 @@ struct type_caster<wpi::math::PyTrajectoryConstraint> {
5958
}
6059
};
6160

62-
} // namespace detail
63-
} // namespace pybind11
61+
} // namespace pybind11::detail

wpiutil/src/main/python/wpiutil/src/wpistruct/wpystruct.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ struct WPyStruct {
5151
py::object py;
5252
};
5353

54-
namespace pybind11 {
55-
namespace detail {
54+
namespace pybind11::detail {
5655

5756
template <>
5857
struct type_caster<WPyStruct> {
@@ -73,8 +72,7 @@ struct type_caster<WPyStruct> {
7372
}
7473
};
7574

76-
} // namespace detail
77-
} // namespace pybind11
75+
} // namespace pybind11::detail
7876

7977
//
8078
// Struct info class implementation

wpiutil/src/main/python/wpiutil/src/wpistruct/wpystruct_fns.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ py::typing::List<WPyStruct> unpackArray(const py::type& t,
138138

139139
auto items = req.size / sz;
140140
py::list a(items);
141-
const uint8_t* ptr = (const uint8_t*)req.ptr;
141+
const uint8_t* ptr = reinterpret_cast<const uint8_t*>(req.ptr);
142142
for (py::ssize_t i = 0; i < items; i++) {
143143
auto s = std::span(ptr, sz);
144144
auto v = wpi::util::UnpackStruct<WPyStruct, WPyStructInfo>(s, info);

wpiutil/src/test/python/cpp/wpiutil_test/sendable_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class MySendableBuilder : public wpi::util::SendableBuilder {
1414
public:
1515
explicit MySendableBuilder(py::dict keys) : keys(keys) {}
1616

17-
~MySendableBuilder() {
17+
~MySendableBuilder() override {
1818
// leak this so the python interpreter doesn't crash on shutdown
1919
keys.release();
2020
}

0 commit comments

Comments
 (0)