An abstract lightweight tree class for managing tree structures.
Requires Python 3.11 or newer.
Development
Use a current uv release; development and package builds are verified with uv 0.13.1. Older uv releases may fail to extract archives used by the current build backend.
uv sync --locked
uv run pytest
uv run mypy verysimpletree --strict
uv run ruff check .
uv run ruff format --check .
uv build
GitLab CI and releases
The root .gitlab-ci.yml runs lint and strict type checks, tests Python
3.11-3.14, and builds a wheel and source distribution. Merge requests, branch
pushes, and tags run validation; duplicate branch pipelines are skipped for
pushes with an open merge request. Jobs explicitly select their Python
interpreter rather than relying on the development .python-version pin.
JUnit test reports and built distributions are retained as job artifacts.
To enable publishing on GitLab:
- Use a runner that supports the configured Python Docker images.
- Protect release tags matching
v*and restrict who can create them. - Add
UV_PUBLISH_TOKENas a masked, protected CI/CD variable containing a PyPI API token scoped to theverysimpletreeproject. - Set the version in
pyproject.toml, updateuv.lock, and commit the changes. - Push a matching stable version tag, such as
v2.0.1.
Publishing runs automatically only for protected stable version tags, after checks, tests, and the build pass. The tag must match the package version. The publish job uploads the build job's artifacts without rebuilding them. Branch and merge request pipelines never publish.
Structural mutations
parent.add_child(child)appends a detached child and returns it.parent.insert_child(index, child)inserts a detached child and returns it. Indices followlist.insert(): negative indices count from the end, and out-of-range indices are clamped.parent.remove(child)detaches a direct child.parent.replace_child(old, new, index=0)replaces a direct child in place.oldcan also be a predicate;indexselects among matching children. Replacing a child with itself is a no-op. The method returnsNone.
Children must have no parent before attachment. Self-insertion, ancestor
insertion, and attaching an already-parented child raise ValueError.
Subclass child-type checks still apply. Invalid attachments leave the tree
unchanged. To move a child, remove it from its old parent first:
old_parent.remove(child)
new_parent.add_child(child)
Mutation methods update parent pointers, leaf status, and affected traversal, leaf, and ancestor-path caches.
Subclass contract
Implement _check_child_to_be_added() to validate allowed child types, raising
an exception for invalid children without mutating the tree. Structural checks
are shared by add_child(), insert_child(), and replace_child() through
_validate_child_attachment().
Inherited structural operations use _children as their authoritative child
storage. Overriding get_children() alone does not provide alternative-storage
support. Subclasses using _children should reuse the mutation methods rather
than assign parent pointers or edit child lists directly.
get_children() still returns the mutable backing list for compatibility.
Direct edits bypass validation and cache invalidation.
Metadata
Release files for verysimpletree 2.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| verysimpletree-2.0.1.tar.gz | 14.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| verysimpletree-2.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.9 kB
Release files / verysimpletree-2.0.1.tar.gz
| Download URL | verysimpletree-2.0.1.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
087fb5ddcc031e527a4aeef340b70eb0c63385e1a08fffbe9902d8860efc7d21
|
|
BLAKE2b-256 checksum How to use checksums |
f578f62e5f85484dbea59ba1b275ae3f6e8b6c84f18fcc05fee58c8d332747b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / verysimpletree-2.0.1-py3-none-any.whl
| Download URL | verysimpletree-2.0.1-py3-none-any.whl |
|---|---|
| Size | 14.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d70ba51319cb2f080c6e33c0a1946539443ff3129c03a159c6b63938ca41b08d
|
|
BLAKE2b-256 checksum How to use checksums |
0bae36fd131a50e2e0e693a052c4002e9e38b9ae17e5550c540d14f70bf89908
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|