Python API typing, lint, config/makefile #3023
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I realise this is a relatively enormous-looking PR; however, I promise it is a LOT less involved than it may initially look! 🤣 (And there are zero logical/functional changes).
Summary
I made a few smaller PRs to add Polars support to Kùzu recently, and working with (and testing) the Python module had a little friction, so I thought I'd reduce it.
Specifically:
ruff check
2 andmypy
3 linting rules.ruff format
4 (this is likely worth integrating into CI and/or pre-commit, but I haven't done that). The existing formatting actually changed very little, so this change mostly just ensures consistent string quoting and max line-length. I set line-length at a level that would result in minimal change.os.path
forpathlib.Path
.tools/python_api
that can:.venv
for testing/validating changes.uv
)5.make python
build from the existing root Makefile.Being able to quickly get up and running in a virtual environment and trigger builds/tests is now a lot smoother, and all the configuration for
mypy
&ruff
is centralised in the new/addedpyproject.toml
file (which is based on what we use for Polars, with Kùzu-specific customisation).Examples
Find out what the Makefile can do:
Install/update the venv requirements:
Check lint and apply formatting:
Run unit tests:
...and so on 👌
CLA
(In case this is a "per-PR" requirement?)
I have read and agree to the terms under
CLA.md
Footnotes
https://peps.python.org/pep-0484/ ↩
https://astral.sh/ruff ↩
https://mypy-lang.org/ ↩
https://docs.astral.sh/ruff/formatter/ ↩
https://astral.sh/blog/uv ↩