-
Notifications
You must be signed in to change notification settings - Fork 0
QDB-16709 - Add stubgen support #97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds stub generation support by providing .pyi files, enforcing direct instantiation guards in C++ bindings, and aligning the return value of cluster.find with cluster.query.
- Introduces a new stub module (
.pyi) for the QuasarDB Python API. - Replaces default constructors on protected classes with lambdas that throw
DirectInstantiationError. - Updates
cluster.findto return astd::vector<std::string>directly and adjusts the binding.
Reviewed Changes
Copilot reviewed 53 out of 53 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| quasardb/quasardb/__init__.pyi | New stub file defining the public Python API |
| properties.hpp, perf.hpp, options.hpp, … | Modified bindings to throw DirectInstantiationError in py::init lambdas |
| cluster.hpp / cluster.cpp | Changed find to return a vector<string> and updated its binding |
| module.cpp | Initialized never_expires via Python’s datetime.fromtimestamp |
| dev-requirements.txt | Added mypy and pybind11-stubgen in development requirements |
Comments suppressed due to low confidence (3)
quasardb/cluster.hpp:340
- [nitpick] The variable name
ois vague; consider renaming it to something more descriptive likequery_objorfinder.
auto o = std::make_shared<qdb::find_query>(_handle, query_string);
quasardb/cluster.hpp:335
- Add or update unit tests for the new
findimplementation that directly returnsstd::vector<std::string>to verify correct behavior.
qdb::find_query find(const std::string & query_string)
quasardb/quasardb/init.pyi:83
- The
metricssymbol is included in__all__but never imported; either add its import (e.g.from ._perf import metrics) or remove it from__all__.
"metrics",
Worked with
pybind11-stubgenas base tool, which produced more accurate results thanstubgenfrommypy.Summary of Changes
.pyistub files for all exposed C++ modules.qdb::handlein their constructors can no longer be directly instantiated. This is enforced via the following binding:.def(py::init([](py::args, py::kwargs) { throw qdb::direct_instantiation_exception{}; return nullptr; }))quasardbstub module to prevent direct instantiation. They still can be imported at runtime, but no type hints will be shown.conn.find()now returns the result directly, aligning its behavior withconn.query()for consistency.