Skip to main content

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:

  1. Use a runner that supports the configured Python Docker images.
  2. Protect release tags matching v* and restrict who can create them.
  3. Add UV_PUBLISH_TOKEN as a masked, protected CI/CD variable containing a PyPI API token scoped to the verysimpletree project.
  4. Set the version in pyproject.toml, update uv.lock, and commit the changes.
  5. Push a matching stable version tag, such as v2.0.0.

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 follow list.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. old can also be a predicate; index selects among matching children. Replacing a child with itself is a no-op. The method returns None.

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.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for verysimpletree 2.0.0
File Size Uploaded
verysimpletree-2.0.0.tar.gz 14.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for verysimpletree 2.0.0
File Interpreter ABI Platform
verysimpletree-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.0 kB

Release files / verysimpletree-2.0.0.tar.gz

Download URL verysimpletree-2.0.0.tar.gz
Size 14.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c3b2eea1318f521519aaf8bd5c5203e4b6a2d7a19cefa96746b92d27cdf98c53
BLAKE2b-256 checksum
How to use checksums
e196220635a32a11ae40ff38de0b1b85f442b966dbd300981ef629bad5516673
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.0-py3-none-any.whl

Download URL verysimpletree-2.0.0-py3-none-any.whl
Size 14.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6faa267e84a7d7e1bb47ff89e68b1c240fd7f2ac5515233db0c1ebb2dd360f07
BLAKE2b-256 checksum
How to use checksums
323492834f78f1e071e721ca5aa424411b0034a6ed4ef72ea2daebfde3ed4106
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}
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page