fix(clang-tidy): performance fixes applied in tests and CI (#3051)

* Initial fixes

* Whoops

* Finish clang-tidy manual fixes

* Add two missing fixes

* Revert

* Update clang-tidy

* Try to fix unreachable code error

* Move nolint comment

* Apply missing fix

* Don't override clang-tidy config

* Does this fix clang-tidy?

* Make all clang-tidy errors visible

* Add comments about NOLINTs and remove a few

* Fix typo
This commit is contained in:
Aaron Gokaslan
2021-06-22 12:11:54 -04:00
committed by GitHub
parent 3b30b0a51e
commit dac74ebdf5
36 changed files with 664 additions and 431 deletions

View File

@@ -8,7 +8,9 @@
*/
#include "test_exceptions.h"
#include "pybind11_tests.h"
#include <utility>
// A type that should be raised as an exception in Python
class MyException : public std::exception {
@@ -199,6 +201,8 @@ TEST_SUBMODULE(exceptions, m) {
throw py::error_already_set();
});
// Changing this broke things. Don't know why
// NOLINTNEXTLINE(performance-unnecessary-value-param)
m.def("python_call_in_destructor", [](py::dict d) {
try {
PythonCallInDestructor set_dict_in_destructor(d);
@@ -210,21 +214,23 @@ TEST_SUBMODULE(exceptions, m) {
return false;
});
m.def("python_alreadyset_in_destructor", [](py::str s) {
m.def("python_alreadyset_in_destructor", [](const py::str &s) {
PythonAlreadySetInDestructor alreadyset_in_destructor(s);
return true;
});
// test_nested_throws
m.def("try_catch", [m](py::object exc_type, py::function f, py::args args) {
try { f(*args); }
catch (py::error_already_set &ex) {
if (ex.matches(exc_type))
py::print(ex.what());
else
throw;
}
});
m.def("try_catch",
[m](const py::object &exc_type, const py::function &f, const py::args &args) {
try {
f(*args);
} catch (py::error_already_set &ex) {
if (ex.matches(exc_type))
py::print(ex.what());
else
throw;
}
});
// Test repr that cannot be displayed
m.def("simple_bool_passthrough", [](bool x) {return x;});