Repository navigation
DataModel: a key-value-pairs mixin, used by the CI and ControlFlow models - #571
Merged
Merged
Conversation
…dels. 'pyTooling.CI.Base' and 'pyTooling.ControlFlow.Base' carried the same copy of the key-value-pair dictionary and its operators; Tree, Graph and Tracing carry further copies. * 'pyTooling.DataModel' (new package): foundations of data models. * 'KeyValuePairsMixin': '_dict: dict[Hashable, Any]', '[]', 'del', 'in', 'len()', iteration over the keys; the initial pairs must be a mapping. * 'BaseWithKeyValuePairs': slotted, abstract base-class materializing the mixin. * 'CI.Base' and 'ControlFlow.Base' derive from 'BaseWithKeyValuePairs'. * Documentation: page 'Data Model Foundations', News. Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Documentation | 2 minor |
🟢 Metrics 4 complexity · 3 duplication
Metric Results Complexity 4 Duplication 3
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Paebbels
requested changes
Oct 17, 2026
…ors as a list. - 'pyTooling/DataModel/__init__.py': FigLet banner 'pyTooling.DataModel' instead of the copied 'pyTooling.ControlFlow'. - 'tests/unit/DataModel/*': same banner, 'Copyright 2026-2026' instead of the copied 'pyTooling.Exceptions' header. - 'from __future__ import annotations' like the sibling modules. - 'KeyValuePairsMixin' doc-string lists the dictionary operators as bullets. - Two blank lines before the module guard of the test file. Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
This was referenced Oct 17, 2026
Merged
Merged
Merged
Merged
Merged
Merged
Merged
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.
pyTooling.CI.BaseandpyTooling.ControlFlow.Basecarried the same copy of the key-value-pair dictionary and its operators, and #570 would have added a third forRule. Following the review of #570, the code moves into a mixin in a new packagepyTooling.DataModel, for data model foundations. It can't go intopyTooling.Common: a mixin needsExtendedType, andpyTooling.MetaClassesimportspyTooling.Common.New Features
pyTooling.DataModel(new package): foundations of data models.KeyValuePairsMixin: arbitrary key-value-pairs on an element, accessed like a dictionary -element[key],element[key] = value,del element[key],key in element,len(element), iteration over the keys in the order they were added. The field is_dict: dict[Hashable, Any]. The initial pairs are given as a mapping and copied.BaseWithKeyValuePairs: the slotted, abstract base-class of a data model whose elements all carry key-value-pairs; it materializes the mixin's field as its slot.Changes
pyTooling.CI.BaseandpyTooling.ControlFlow.Basederive fromBaseWithKeyValuePairs; their own copies of the dictionary and its six operators are removed.keyValuePairsgiven as anything but a mapping - e.g. a list of pairs - raises aTypeError. Before,dict(...)converted it silently. Both packages are new in v10.0.0, so this only breaks code written against the release candidates.Documentation
DataStructures/DataModel): the operators, the mapping check, and when to derive fromBaseWithKeyValuePairsvs. addKeyValuePairsMixinto a class with a base-class of its own.News: entry forpyTooling.DataModel.Unit Tests
tests/unit/DataModel/KeyValuePairs.py(new): empty element, initial pairs are copied, non-mapping rejected, operators, missing keys, the mixin on a class of another slotted line (still without__dict__),BaseWithKeyValuePairsis abstract.Related Issues and Pull-Requests
Rulederives fromBaseWithKeyValuePairs.Tree.Node(its__len__counts children and replaces the key-value one),Graph.Base(typed keys and values),Tracing.TraceElement(iterates(key, value)pairs), pyEDAA.Reports'KeyValuePairsMixin(strkeys,_keyValuePairs). Each needs its own decision.