sourcery-ai / sourcery

Instant AI code reviews
https://sourcery.ai
MIT License
1.55k stars 70 forks source link

Sourcery uses spaces even when code uses tabs. #251

Closed MinekPo1 closed 2 years ago

MinekPo1 commented 2 years ago

In the following code:

def very_long_function_name_to_force_sourcery_to_split_the_expression_into_multiple_lines():
    return True

def test():
    l = []
    for i in range(20):
        l.append(very_long_function_name_to_force_sourcery_to_split_the_expression_into_multiple_lines())

Sourcery suggests a refactoring. However when it is accepted:

def very_long_function_name_to_force_sourcery_to_split_the_expression_into_multiple_lines():
    return True

def test():
    l = [
        very_long_function_name_to_force_sourcery_to_split_the_expression_into_multiple_lines(
        ) for _ in range(20)
    ]

Running it will cause a syntax error for mixing spaces and tabs. Its not clear here, so I will post screenshots from my editor:

image

image

I understand that I am in the minority of python users using tabs and that it is against PEP-8, however I think that code produced by Sourcery should not produce errors.

Sourcery Version

Can't find it for some reason

Code editor or IDE name and version

VSCode v1.69.0

OS name and version

Windows 10.0.19044 (sadly)

brendanator commented 2 years ago

Thanks for reporting this @MinekPo1. I have found a fix which will be in the next release

Hellebore commented 2 years ago

Resolved with new release.