spock-yh opened a new pull request, #1485: URL: https://github.com/apache/hamilton/pull/1485
Fixes #1484 ## Changes - **`hamilton/graph_utils.py`**: Changed `is_submodule()` from substring matching (`parent.__name__ in child.__name__`) to proper prefix matching (`child.__name__.startswith(parent.__name__ + ".")`), plus an equality check for the same-module case. Added a `None` guard for when `inspect.getmodule()` returns `None`. - **`tests/test_graph.py`**: Added 9 parametrized `test_is_submodule` cases and 1 end-to-end regression test (`test_find_functions_excludes_imports_with_substring_module_name`). ## Breaking Change This is a bugfix, but it **changes observable behavior**: previously, if a user module's name happened to be a substring of an imported function's module path (e.g., a module named `modifiers` importing from `hamilton.function_modifiers`), those imported functions would silently appear as DAG nodes. After this fix, they will no longer appear. Users who were unknowingly relying on this behavior (imported functions showing up as nodes) 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. ## How I tested this - `prek run --all-files` — all hooks pass - `uv run pytest tests/ --ignore tests/integrations` — 1424 passed (7 pre-existing failures due to missing system-level graphviz binary and Chrome, unrelated to this change) - The new regression test creates a synthetic module named `"modifiers"` with imports from `hamilton.function_modifiers`, verifying only the user-defined function appears in `find_functions()` output ## Checklist - [x] PR has an informative and human-readable title (this will be pulled into the release notes) - [x] Changes are limited to a single goal (no scope creep) - [x] Code passed the pre-commit check & code is left cleaner/nicer than when first encountered - [x] Any _change_ in functionality is tested - [x] New functions are documented (with a description, list of inputs, and expected output) - [x] Placeholder code is flagged / future TODOs are captured in comments - [x] Project documentation has been updated if adding/changing functionality 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
