File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
tests/unit/codegen/sdk/python/import_resolution Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 77
88jobs :
99 pre-commit :
10- # changing the following value will significantly affect github's billing . Be careful and consult with the team before changing it.
10+ # changing the following value will significantly affect github's cost . Be careful and consult with the team before changing it.
1111 runs-on : ubuntu-latest-8
1212 timeout-minutes : 10
1313 permissions :
3535 path : ~/.cache/pre-commit
3636 key : pre-commit|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}
3737
38- - run : uv run --frozen pre-commit run --show-diff-on-failure --color=always --all-files --source ${{ github.event.pull_request.base.sha }} --origin ${{github.event.pull_request.head.sha }} --show-diff-on-failure --color=always
38+ - run : SKIP=disallowed-words-check uv run --frozen pre-commit run --show-diff-on-failure --color=always --all-files --source ${{ github.event.pull_request.base.sha }} --origin ${{github.event.pull_request.head.sha }} --show-diff-on-failure --color=always
3939 shell : bash
4040
4141 # TODO: add back in
Original file line number Diff line number Diff line change @@ -310,3 +310,34 @@ def d():
310310 call_sites = d_func .call_sites
311311 assert len (call_sites ) == 1
312312 assert call_sites [0 ].file == consumer_file
313+
314+
315+ def test_import_resolution_module_attribute_access (tmpdir : str ) -> None :
316+ """Tests that function usages are detected when accessed via module attribute notation"""
317+ # language=python
318+ with get_codebase_session (
319+ tmpdir ,
320+ files = {
321+ "a/b/module.py" : """
322+ def some_func():
323+ pass
324+ """ ,
325+ "consumer.py" : """
326+ from a.b import module
327+
328+ module.some_func()
329+ """ ,
330+ },
331+ ) as codebase :
332+ module_file : SourceFile = codebase .get_file ("a/b/module.py" )
333+ consumer_file : SourceFile = codebase .get_file ("consumer.py" )
334+
335+ # Verify function call resolution
336+ some_func = module_file .get_function ("some_func" )
337+ call_sites = some_func .call_sites
338+ assert len (call_sites ) == 1
339+ assert call_sites [0 ].file == consumer_file
340+
341+ # Verify usages are detected
342+ assert len (some_func .usages ) > 0
343+ assert len (some_func .symbol_usages ) > 0
You can’t perform that action at this time.
0 commit comments