MCPcopy Index your code
hub / github.com/RustPython/RustPython / visit_Call

Method visit_Call

scripts/update_lib/deps.py:80–114  ·  view source on GitHub ↗

In test files, there's sometimes use of: ```python import test.support from test.support import script_helper script = support.findfile("_test_atexit.py") script_helper.run_test_script(script) ``` This imports "_test_atexit.py" but

(self, node)

Source from the content-addressed store, hash-verified

78 self.__imports.add(name)
79
80 def visit_Call(self, node) -> None:
81 """
82 In test files, there's sometimes use of:
83
84 ```python
85 import test.support
86 from test.support import script_helper
87
88 script = support.findfile("_test_atexit.py")
89 script_helper.run_test_script(script)
90 ```
91
92 This imports "_test_atexit.py" but does not show as an import node.
93 """
94 func = node.func
95 if not isinstance(func, ast.Attribute):
96 return
97
98 value = func.value
99 if not isinstance(value, ast.Name):
100 return
101
102 if (value.id != "support") or (func.attr != "findfile"):
103 return
104
105 arg = node.args[0]
106 if not isinstance(arg, ast.Constant):
107 return
108
109 target = arg.value
110 if not target.endswith(".py"):
111 return
112
113 target = target.removesuffix(".py")
114 self.__imports.add(f"test.{target}")
115
116
117def parse_test_imports(content: str) -> frozenset[str]:

Callers

nothing calls this directly

Calls 4

isinstanceFunction · 0.85
endswithMethod · 0.45
removesuffixMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected