Skip to content

Commit 676a023

Browse files
Drop pybind11 module_local() from bound-type registrations (#512)
Remove the 6 py::module_local() annotations (DuckDBPyConnection, Statement, Expression, Relation, Type class_ registrations + the token_type enum).
2 parents 680cb27 + 467b48e commit 676a023

6 files changed

Lines changed: 7 additions & 9 deletions

File tree

src/duckdb_py/duckdb_python.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ PYBIND11_MODULE(DUCKDB_PYTHON_LIB_NAME, m) { // NOLINT
11061106
"Tokenizes a SQL string, returning a list of (position, type) tuples that can be "
11071107
"used for e.g., syntax highlighting",
11081108
py::arg("query"));
1109-
py::enum_<PySQLTokenType>(m, "token_type", py::module_local())
1109+
py::enum_<PySQLTokenType>(m, "token_type")
11101110
.value("identifier", PySQLTokenType::PY_SQL_TOKEN_IDENTIFIER)
11111111
.value("numeric_const", PySQLTokenType::PY_SQL_TOKEN_NUMERIC_CONSTANT)
11121112
.value("string_const", PySQLTokenType::PY_SQL_TOKEN_STRING_CONSTANT)

src/duckdb_py/pyconnection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ DuckDBPyConnection::RegisterScalarUDF(const string &name, const py::function &ud
454454
}
455455

456456
void DuckDBPyConnection::Initialize(py::handle &m) {
457-
auto connection_module = py::class_<DuckDBPyConnection, std::shared_ptr<DuckDBPyConnection>>(
458-
m, "DuckDBPyConnection", py::module_local());
457+
auto connection_module =
458+
py::class_<DuckDBPyConnection, std::shared_ptr<DuckDBPyConnection>>(m, "DuckDBPyConnection");
459459

460460
connection_module.def("__enter__", &DuckDBPyConnection::Enter)
461461
.def("__exit__", &DuckDBPyConnection::Exit, py::arg("exc_type"), py::arg("exc"), py::arg("traceback"));

src/duckdb_py/pyexpression/initialize.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,7 @@ static void InitializeImplicitConversion(py::class_<DuckDBPyExpression, std::sha
301301
}
302302

303303
void DuckDBPyExpression::Initialize(py::module_ &m) {
304-
auto expression =
305-
py::class_<DuckDBPyExpression, std::shared_ptr<DuckDBPyExpression>>(m, "Expression", py::module_local());
304+
auto expression = py::class_<DuckDBPyExpression, std::shared_ptr<DuckDBPyExpression>>(m, "Expression");
306305

307306
InitializeStaticMethods(m);
308307
InitializeDunderMethods(expression);

src/duckdb_py/pyrelation/initialize.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static void InitializeMetaQueries(py::class_<DuckDBPyRelation> &m) {
274274
}
275275

276276
void DuckDBPyRelation::Initialize(py::handle &m) {
277-
auto relation_module = py::class_<DuckDBPyRelation>(m, "DuckDBPyRelation", py::module_local());
277+
auto relation_module = py::class_<DuckDBPyRelation>(m, "DuckDBPyRelation");
278278
InitializeReadOnlyProperties(relation_module);
279279
InitializeAggregates(relation_module);
280280
InitializeWindowOperators(relation_module);

src/duckdb_py/pystatement.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ static void InitializeReadOnlyProperties(py::class_<DuckDBPyStatement, std::uniq
1515
}
1616

1717
void DuckDBPyStatement::Initialize(py::handle &m) {
18-
auto relation_module =
19-
py::class_<DuckDBPyStatement, std::unique_ptr<DuckDBPyStatement>>(m, "Statement", py::module_local());
18+
auto relation_module = py::class_<DuckDBPyStatement, std::unique_ptr<DuckDBPyStatement>>(m, "Statement");
2019
InitializeReadOnlyProperties(relation_module);
2120
}
2221

src/duckdb_py/typing/pytype.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static LogicalType FromObject(const py::object &object) {
327327
}
328328

329329
void DuckDBPyType::Initialize(py::handle &m) {
330-
auto type_module = py::class_<DuckDBPyType, std::shared_ptr<DuckDBPyType>>(m, "DuckDBPyType", py::module_local());
330+
auto type_module = py::class_<DuckDBPyType, std::shared_ptr<DuckDBPyType>>(m, "DuckDBPyType");
331331

332332
type_module.def("__repr__", &DuckDBPyType::ToString, "Stringified representation of the type object");
333333
type_module.def("__eq__", &DuckDBPyType::Equals, "Compare two types for equality", py::arg("other"),

0 commit comments

Comments
 (0)