Skip to content

Preserve nested Dict error context - #999

Open
ViktorBystrov72 wants to merge 1 commit into
ipython:mainfrom
ViktorBystrov72:fix/nested-dict-validation-errors
Open

ViktorBystrov72 wants to merge 1 commit into
ipython:mainfrom
ViktorBystrov72:fix/nested-dict-validation-errors

Conversation

@ViktorBystrov72

Copy link
Copy Markdown

Identify the offending key when Dict(per_key_traits=...) rejects a value, and preserve the expected type through nested dictionaries and containers. A bad string inside a nested dictionary is no longer reported as a dictionary that must be a dictionary; errors involving a list retain the list context.

Regression cases cover the reported schema, nested dictionaries and lists, custom TraitError messages, and the existing fallback value_trait diagnostics.

Related to the closed #978, which added an outer key label while leaving nested diagnostics outside its scope. This change carries the existing TraitError context through the per-key validation path.

Fixes #920.

AI assistance: Codex assisted with the implementation and regression tests. 🤖🤖

@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.25%. Comparing base (a576f24) to head (617b73e).

Components Coverage Δ
traitlets 85.67% <100.00%> (+0.04%) ⬆️
tests 99.08% <100.00%> (+<0.01%) ⬆️

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

traitlets Dict with per_key_traits should be more specific in a TraitError

1 participant