Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving Python Symbols with Wildcard Imports #1953

Open
code2graph opened this issue Aug 18, 2023 · 1 comment
Open

Resolving Python Symbols with Wildcard Imports #1953

code2graph opened this issue Aug 18, 2023 · 1 comment

Comments

@code2graph
Copy link

code2graph commented Aug 18, 2023

Does jedi support wild card import and unto what extent?

I've been using this library to analyze a Python project and extract symbol definitions and references. But I've encountered an issue when dealing with wildcard imports (import *).

Example:

Consider the following code structure:

# utils.py
def check_files_in_directory():
    pass
# main.py
from utils import *

def main():
    check_files_in_directory()

When I try to resolve the check_files_in_directory function in main.py, it fails to determine its origin due to the wildcard import.

What I've tried:

I've successfully resolved symbols for explicit imports, e.g., from utils import check_files_in_directory.

Question:

Is there a way to make jedi resolve symbols imported with wildcard imports effectively? I understand wildcard imports can be challenging for static analysis tools since they obfuscate the origin of symbols. **Do I have to set some configuration? For my case, even if it the analysis takes time and it is slow to resolve it, that is not a problem.

@code2graph code2graph changed the title Support for wild card import Resolving Python Symbols with Wildcard Imports Aug 18, 2023
@davidhalter
Copy link
Owner

This kind of stuff is well supported within Jedi. It even works in places like numpy that does nested star imports. I feel like you have either an outdated Jedi version or you are not using Jedi (accidentally) or most likely there's an issue with your sys path or the sys path you provide to Jedi.

If you want me to help, you have to write a full reproduction with a zip archive that I could look at.

Also note that this is a feature we have had zero complaints about for probably 7+ years. It is also automatically tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants