Skip to content

Restructure modules and class hierarchy

Patrick Godwin requested to merge patrick.godwin/sgn:restructure into main

Address a lot of the type checking issues by restructuring the dataclass class hierarchy a bit. I also found a way to get around optional attributes with class inheritance without needing a complex solution or python 3.10 (see the base Pad class). In doing so, I had thought that some of pad properties would not be optional, but turns out they are since they get set after the pads themselves are linked.

I also flattened the module hierarchy since the nested module structure seemed unnecessary. Note, this doesn't change the public API in any way.

Also some minor linting.

All in all, we're down to a single error raised by mypy:

make type-check
mypy .
src/sgn/apps.py:64: error: Argument 1 to "update" of "MutableMapping" has incompatible type "dict[SinkPad, set[SourcePad]]"; expected "SupportsKeysAndGetItem[SourcePad, set[SinkPad]]"  [arg-type]

So here's an interesting one. SinkPad.link returns dict[SinkPad, set[SourcePad]] but Element.graph stores dict[SourcePad, set[SinkPad]]. Both are stored in Pipeline.graph, yet the graph execution seems to work. I don't understand how this ends up working, but I could be missing something. Not sure how to resolve this as-is.

The above has been there before this MR so isn't a blocker for merging.

Merge request reports

Loading