code_diff icon indicating copy to clipboard operation
code_diff copied to clipboard

Runtime error with readme demo test

Open alphatogo opened this issue 1 year ago • 1 comments

Thank you for your contribution, but I encountered an issue when running cd.difference: AttributeError: partially initialized module 'code_diff' has no attribute 'difference' (most likely due to a circular import). Could you please help explain why this bug occurs?

import code_diff as cd

# Python
output = cd.difference(
    '''
        def my_func():
            print("Hello World")
    ''',
    '''
        def say_helloworld():
            print("Hello World")
    ''',
lang = "python")

# Output: my_func -> say_helloworld

output.edit_script()

# Output: 
# [
#  Update((identifier:my_func, line 1:12 - 1:19), say_helloworld)
#]


# Java
output = cd.difference(
    '''
        int x = x + 1;
    ''',
    '''
        int x = x / 2;
    ''',
lang = "java")

# Output: x + 1 -> x / 2

output.edit_script()

# Output: [
#  Insert(/:/, (binary_operator, line 0:4 - 0:9), 1),
#  Update((integer:1, line 0:8 - 0:9), 2),
#  Delete((+:+, line 0:6 - 0:7))
#]

alphatogo avatar Nov 14 '24 10:11 alphatogo

Sorry for the delayed answer. Sadly, I have no idea why this problem occurs. Did you fix the problem in the meantime? Or could you give some further hints about your setup? Thanks!

cedricrupb avatar Jan 14 '25 09:01 cedricrupb