-
Notifications
You must be signed in to change notification settings - Fork 28
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
The Python-sdk does not handle an import that has been renamed to an alias such as import pandas as pd
.
To Reproduce
Steps to reproduce the behavior:
- Run this code:
from cldk.analysis.python.treesitter import PythonSitter
code = """
import io
from flask import Flask
import pandas as pd
def hello():
print("Hello!")
"""
if __name__ == "__main__":
python_sitter = PythonSitter()
print("Statements:\n")
import_statements = python_sitter.get_all_imports(code)
for statement in import_statements:
print(statement)
print("\nDetails:\n")
import_details = python_sitter.get_all_imports_details(code)
for detail in import_details:
print(detail)
Expected behavior
I expect to get all of the imports parsed correctly from the get_all_imports_details()
method.
Instead I got this output:
Statements:
import io
import pandas as pd
from flask import Flask
Details:
from_statement='' imports=['io']
from_statement='' imports=[]
from_statement='flask' imports=['Flask']
Notice the from_statement='' imports=[]
in the output instead of the pandas
import.
Logs
If applicable, add logs to help explain your problem.
Additional context
Add any other context about the problem here.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working