Resolving Python Symbols with Wildcard Imports using python-lsp-server

70 Views Asked by At

I've been using the python-lsp-server to analyze a Python project and extract symbol definitions and references. The server works well for explicit imports, 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 using the LSP server, it fails to determine its origin due to the wildcard import.

What I've tried:

  1. I've successfully resolved symbols for explicit imports, e.g., from utils import check_files_in_directory.
  2. I've checked the LSP server's capabilities and ensured I'm sending the correct requests.

Question:

Is there a way to make python-lsp-server resolve symbols imported with wildcard imports effectively? Do I have to set some configuration? For my case, even if it takes time or slow to resolve it, that is not a problem.

Wildcard imports can be challenging for static analysis tools since they obfuscate the origin of symbols. I'm looking for a solution that can handle this scenario, whether it's a configuration or a combination of strategies.

0

There are 0 best solutions below