Repository navigation
Typed package: ship py.typed in both wheels and put type hints on every public class and function - #481
Merged
Conversation
…ry public class and function Neither wheel had a py.typed marker, so an editor or a type checker treated arcadedb as untyped even where the code had hints (PEP 561). The marker is a package-data entry in both package definitions (pyproject.toml for arcadedb-jvm, native/wheel/pyproject.toml for arcadedb): setuptools ships nothing that is not listed. The public callables had 180 of 258 return hints and 362 of 469 parameter hints; now 258 of 258 and 469 of 469 (modules without a leading underscore, counted by AST). The 106 additions are hints only, with Any for what the JVM or the native library hands over (java_* parameters, Java records) and a TypeVar on run_in_transaction so the result keeps its type. Forward references use TYPE_CHECKING imports, so nothing new is imported at run time. Code that mypy now checks changed shape without changing behavior: four declarations got a type (server._java_server, Database._async_executors, ResultSet._facets, a stats dict), and run_in_transaction ends with an explicit "return None" for retries < 0, which fell off the end before. No stub file: every public name is defined in a .py file that carries its hints. The native layer (arcadedb._native) is private; its database class has the Database surface and is returned under the name Database, so the hints name Database for both builds. The four call sites in _native/database.py that pass a NativeDatabase to a function that names Database carry a type: ignore for that. Tests (tests/test_typed_package.py, both builds): the marker is in the installed package, both package definitions list it, every public callable of arcadedb.__all__ and arcadedb.aio.AsyncDatabase has hints on every parameter and a return hint, and the entry points name the Database type. tests/test_wheel_packages.py checks that the JVM build ships the marker. Built the way CI builds them (native: native/wheel/build_wheel.py with the library of the main wheel; JVM: uv build of the package definition without jars), both wheels list arcadedb/py.typed. mypy (laptop, once, no CI job: the repo has no type checker configured): 66 error lines before, 65 after, none of the new ones from the hints (new findings in bodies that mypy now checks were fixed); what remains is older code in private modules and the "jpype = None" fallbacks.
This was referenced Nov 24, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this PR do?
Both wheels ship a
py.typedmarker (PEP 561), and every public class and function has type hints, so editors and type checkers readarcadedbas a typed package.src/arcadedb/py.typedis listed as package data in both package definitions (pyproject.tomlforarcadedb-jvm,native/wheel/pyproject.tomlforarcadedb). I built both wheels the way CI does (native withnative/wheel/build_wheel.pyand the library of the main wheel, JVM withuv buildof the package definition without jars): each listsarcadedb/py.typed.Anystands for what the JVM or the native library hands over,run_in_transactionhas aTypeVarso the result keeps its type, and forward references useTYPE_CHECKINGimports, so nothing new is imported at run time..pyfile that carries its hints. The native classes underarcadedb._nativeare private and are returned under the public names (Databaseand the rest), so one set of hints serves both builds.mypy, laptop, run once with
uv run --with mypy(no CI job: the repo has no type checker configured, so I did not add one): 66 error lines onmain, 65 on this branch. Annotating a function makes mypy check its body, so the hints surfaced a few findings in bodies it had skipped; I fixed those (four declarations got a type,run_in_transactionends with an explicitreturn Noneforretries < 0, which fell off the end before, and four call sites in_native/database.pythat pass aNativeDatabasewhereDatabaseis named carry atype: ignore). What remains is older code: thejpype = Nonefallbacks, private dicts without a declared type, and the native layer's own classes. A CI type check would need those cleaned first, so it is a separate step.Related issues
Closes #476
Docs
README.mdlists the typed package under "What is included". No docs page describes typing.Milestone
27.1.1. The change is additive and does not touch behavior, but it edits 16 modules (hints, one explicit
return None, four declared types), which is more than I call small for the 26.12.1 cut.Release note draft
Both packages now ship a
py.typedmarker and type hints on every public class and function, so editors and type checkers seearcadedbas typed.Tests
tests/test_typed_package.py, run by both builds: the marker is in the installed package, both package definitions list it, every public callable ofarcadedb.__all__andarcadedb.aio.AsyncDatabasehas hints on every parameter and a return hint, and the entry points name theDatabasetype.tests/test_wheel_packages.pychecks that the JVM build ships the marker. Local run on themainwheels of 2026-11-24 with this branch's Python files laid over them (laptop): 436 passed on the JVM build for the typing tests and 18 other files that exercise the touched modules, 402 passed on the native build, with 21 skips (tests thattests/conftest.pymarks as not applicable on native) and 4 errors (test_vector.pyfixtures that importjpype, which the native wheel does not have; the parity runner does not run those).Checklist
uvx pre-commit run --files <changed files>passes