Fix is_submodule substring match causing spurious DAG nodes#1485
Merged
skrawcz merged 3 commits intoapache:mainfrom Mar 22, 2026
Merged
Fix is_submodule substring match causing spurious DAG nodes#1485skrawcz merged 3 commits intoapache:mainfrom
skrawcz merged 3 commits intoapache:mainfrom
Conversation
skrawcz
reviewed
Feb 21, 2026
tests/test_graph.py
Outdated
| ) | ||
| def test_is_submodule(child_name, parent_name, expected): | ||
| """Tests that is_submodule correctly checks module hierarchy using prefix matching.""" | ||
| from types import ModuleType |
skrawcz
reviewed
Feb 21, 2026
tests/test_graph.py
Outdated
Comment on lines
+109
to
+112
| import sys | ||
| from types import ModuleType | ||
|
|
||
| from hamilton.function_modifiers import source, value |
skrawcz
requested changes
Feb 21, 2026
Contributor
skrawcz
left a comment
There was a problem hiding this comment.
just test clean up. Thanks for fixing this.
a362503 to
8437d02
Compare
skrawcz
approved these changes
Mar 22, 2026
Move `ModuleType` import to top-level and use existing `fm` alias for `source`/`value` instead of inline imports.
8437d02 to
f94c36a
Compare
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.
Fixes #1484
Changes
hamilton/graph_utils.py: Changedis_submodule()from substring matching (parent.__name__ in child.__name__) to proper prefix matching (child.__name__.startswith(parent.__name__ + ".")).tests/test_graph.py: Added 9 parametrizedtest_is_submodulecases and 1 end-to-end regression testBreaking Change
This is a bugfix, but it breaks old behavior: users who were unknowingly relying on this behavior (imported functions showing up as nodes even if not from a submodule) may see nodes disappear from their DAGs after upgrading. Users should verify their DAGs after upgrading to ensure no expected nodes are missing — though in practice, the removed nodes were almost certainly unintended.
Checklist