Skip to main content

tracked-dict

Dict and list wrappers that track key access for reporting unconsumed data.

Wrap a parsed JSON/YAML/TOML structure in TrackedDict, read what you need through normal dict access, then call unaccessed() to get dotted paths for every key that was never touched.

Install

pip install tracked-dict

Usage

import json
from tracked_dict import TrackedDict

with open("config.json") as f:
    data = TrackedDict(json.load(f))

name = data["project"]["name"]
version = data["project"]["version"]

for path in data.unaccessed():
    print(f"  unhandled: {path}")

API

TrackedDict(data: dict, _path: str = "")

  • d[key] / d.get(key, default) — read access; marks key as accessed
  • key in d, len(d), bool(d), iter(d) — standard container ops (do not mark accessed)
  • d.keys() — returns keys (does not mark accessed)
  • d.values() / d.items() — iterate with wrapping; marks all keys accessed
  • d.raw — the underlying plain dict
  • d.mark_accessed(*keys) — explicitly mark keys
  • d.mark_all_accessed() — mark every key at this level
  • d.unaccessed() — sorted list of dotted paths for all unaccessed keys, recursively
  • d.accessed_keys() — set of keys accessed at this level

Nested dicts are automatically wrapped in TrackedDict, nested lists in TrackedList.

TrackedList(data: list, _path: str = "")

  • lst[i], len(lst), bool(lst), iter(lst) — standard access
  • lst.raw — the underlying plain list
  • lst.unaccessed() — collects unaccessed paths from wrapped children

How it works

When you access a key via [] or .get(), TrackedDict records that key. Nested dicts and lists are lazily wrapped on first access so their keys are tracked too. After your parser finishes, unaccessed() walks the tree and returns dotted paths (e.g. "server.timeout", "users[0].email") for anything never read.

This catches both parser omissions (data present but ignored) and unknown user-supplied fields — without maintaining a separate list of expected keys.

License

MIT

Release files for tracked-dict 0.1.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 tracked-dict 0.1.0
File Size Uploaded
tracked_dict-0.1.0.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for tracked-dict 0.1.0
File Interpreter ABI Platform
tracked_dict-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.0 kB

Release files / tracked_dict-0.1.0.tar.gz

Download URL tracked_dict-0.1.0.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0962eeb9b2d0ee577b00010fc8315d0f4b9ba59c470eefa4211e1a2dcfb61fec
BLAKE2b-256 checksum
How to use checksums
9b8826808999945e7338e85fa82e3edfafc3dd26814b8b8918aa2bae47cf6436
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release files / tracked_dict-0.1.0-py3-none-any.whl

Download URL tracked_dict-0.1.0-py3-none-any.whl
Size 5.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
956f548d9c91408d0c64c5c1cdbf24a57275e333ba493b9647c16a7dc4bd19da
BLAKE2b-256 checksum
How to use checksums
17e539dd27beaeeb0f9ffd08cbfeed432baa273632cf7aaae304fb30c9f29e76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

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