Repository navigation
Type parameters of pyTooling.Graph: the kind of an edge or link, and annotations matching the classes - #445
Merged
Merged
Conversation
Merged
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 4 |
| Duplication | 0 |
🟢 Coverage 100.00% diff coverage · +0.00% coverage variation
Metric Results Coverage variation ✅ +0.00% coverage variation Diff coverage ✅ 100.00% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (af2f0eb) 15681 13615 86.82% Head commit (db93349) 15685 (+4) 13619 (+4) 86.83% (+0.00%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#445) 32 32 100.00% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
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
force-pushed
the
claude/graph-edge-typevars
branch
from
September 28, 2026 20:00
7b3d7fb to
4cf0813
Compare
Paebbels
requested changes
Sep 28, 2026
…h in the field annotations The Edge[...] and Link[...] subscripts swapped value and weight against the classes' declaration (ID, value, weight), the links of a vertex used the edge type variables, and BaseGraph._linksWithID was keyed by EdgeIDType. Vertex._graph and Vertex._subgraph gave 12 of 17 parameters - typing.get_type_hints(Vertex) raised 'Too few arguments for BaseGraph' - and BaseWithVertices._graph 17 of 23. Type variables a class doesn't declare are given as Any. Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
BaseEdge.Kind returns EdgeKindType (bound to Enum), so Edge[..., MyKind] gives the user's own enumeration. Edge, Link and every class naming them - Vertex, BaseGraph, Subgraph, View, Component and Graph - carry the kind type variables in their type parameters. A test evaluates the field annotations of the graph classes. Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
…ry's EdgeKindType / LinkKindType precede EdgeDictKeyType / LinkDictKeyType in every declaration and subscript, as the kind precedes keyValuePairs in the constructors: Edge[ID, value, weight, kind, dict key, dict value]. Co-Authored-By: Patrick Lehmann <Paebbels@gmail.com>
Paebbels
force-pushed
the
claude/graph-edge-typevars
branch
from
September 28, 2026 20:32
4cf0813 to
db93349
Compare
This was referenced Oct 12, 2026
Merged
Merged
Merged
This was referenced Oct 20, 2026
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.
New Features
pyTooling.Graph: the kind of an edge or link is a type parameter.EdgeKindTypeandLinkKindType(type variables bound toEnum) are type parameters ofBaseEdge/EdgeandLink, after ID, value and weight and before the dictionary's types - as the kind precedeskeyValuePairsin theconstructors:
Edge[ID, value, weight, kind, dict key, dict value].BaseEdge.KindreturnsEdgeKindType, so auser's
Edge[..., MyKind, ...]typesKindasMyKind.Vertex,BaseGraph,Subgraph,View,Component,Graph.Bug Fixes
pyTooling.Graph: the field annotations didn't match the classes' type parameters.Edge[...]andLink[...]subscripts (Vertex._inboundEdges,_outboundEdges,_inboundLinks,_outboundLinks,BaseGraph._edgesWithID,_edgesWithoutID,_linksWithID,_linksWithoutID,IterateEdges,IterateLinks) swapped value and weight against the declaration(ID, value, weight, ...).BaseGraph._linksWithIDwas keyed byEdgeIDType.Vertex._graphandVertex._subgraphgave 12 of 17 type parameters,BaseWithVertices._graph17 of 23:typing.get_type_hints(Vertex)raisedTypeError: Too few arguments for <class 'pyTooling.Graph.BaseGraph'>.Type variables a class doesn't declare itself (e.g. a subgraph's dictionary types in
Vertex) are given asAny.Known Issues
typing.get_type_hints()still fails forBaseWithVertices,ViewandComponent: their annotationGraph[...]resolves to the class' own property
Graph, not to the classGraph('readonly' object is not subscriptable).Not changed here.
Unit Tests
tests/unit/Graph, classTypeHints: the field annotations ofVertex,Edge,Link,BaseGraph,Subgraphand
Graphevaluate;EdgeKindType/LinkKindTypeare type parameters and the return type ofKind.Related Issues and Pull-Requests
EdgeKind,LinkKindandBaseEdge.Kind.