Skip to content

Commit 8437d02

Browse files
skrawczclaude
andcommitted
Move test imports to top level per review feedback
Move `ModuleType` import to top-level and use existing `fm` alias for `source`/`value` instead of inline imports. Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent ee82049 commit 8437d02

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

tests/test_graph.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import sys
2121
import uuid
2222
from itertools import permutations
23+
from types import ModuleType
2324

2425
import pandas as pd
2526
import pytest
@@ -81,8 +82,6 @@
8182
)
8283
def test_is_submodule(child_name, parent_name, expected):
8384
"""Tests that is_submodule correctly checks module hierarchy using prefix matching."""
84-
from types import ModuleType
85-
8685
child = ModuleType(child_name)
8786
parent = ModuleType(parent_name)
8887
assert hamilton.graph_utils.is_submodule(child, parent) == expected
@@ -108,11 +107,6 @@ def test_find_functions_excludes_imports_with_substring_module_name():
108107
which caused e.g. a module named 'modifiers' to pull in functions from
109108
'hamilton.function_modifiers'.
110109
"""
111-
import sys
112-
from types import ModuleType
113-
114-
from hamilton.function_modifiers import source, value
115-
116110
# Create a fake module named "modifiers" with one real function and two imports
117111
mod = ModuleType("modifiers")
118112

@@ -122,8 +116,8 @@ def my_func(x: int) -> int:
122116
# Assign the function to the module so inspect.getmodule can resolve it
123117
my_func.__module__ = "modifiers"
124118
mod.my_func = my_func
125-
mod.source = source
126-
mod.value = value
119+
mod.source = fm.source
120+
mod.value = fm.value
127121

128122
# Register in sys.modules so inspect.getmodule can find it
129123
sys.modules["modifiers"] = mod

0 commit comments

Comments
 (0)