sourcery-ai / sourcery

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

Multiple conflicting refactoring regressions? #243

Closed diceroll123 closed 2 years ago

diceroll123 commented 2 years ago

Issue description or question

I'll let the code and comments do the talking!

def blah():
    num = "1"
    name = "hello"
    thestring = str(num) + "_" + name
    # sourcery wants to change this to
    # thestring = f"{num}_{name}"
    # this is correct!
    # (I expect this exact output from the below methods as well)
    print(thestring)

def blah1():
    num = 1
    name = "hello"
    thestring = str(num) + "_" + name
    # sourcery wants to change this to
    # thestring = f"{1}_" + "hello"
    print(thestring)

def blah2():
    num = random.randint(0, 100)
    name = "hello"
    thestring = str(num) + "_" + name
    # sourcery wants to change this to
    # thestring = f"{str(num)}_{name}"
    print(thestring)

Thanks for readin'.

Sourcery Version

v0.11.5

Code editor or IDE name and version

VSCode Version: 1.67.2 (user setup) Commit: c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5 Date: 2022-05-17T18:15:52.058Z Electron: 17.4.1 Chromium: 98.0.4758.141 Node.js: 16.13.0 V8: 9.8.177.13-electron.0 OS: Windows_NT x64 10.0.25120

ruancomelli commented 2 years ago

Hello again, @diceroll123!

You are correct, Sourcery should suggest the same thing in blah1 and blah2.

Thanks for raising this, we'll look into it!

brendanator commented 2 years ago

I've identified a fix which will be included in the next release

Hellebore commented 2 years ago

Resolved with release of 0.12.1