Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistency with use-fstring-for-concatenation #222

Closed
diceroll123 opened this issue Apr 9, 2022 · 4 comments
Closed

Inconsistency with use-fstring-for-concatenation #222

diceroll123 opened this issue Apr 9, 2022 · 4 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request next release This will be fixed in next release

Comments

@diceroll123
Copy link

Issue description or question

I can't exactly put my finger on what's going wrong here, y'all must be doing some weird stuff behind the scenes.

def _test_sourcery_thing():
    # does NOT suggest use-fstring-for-concatenation
    # let's call this the original function
    favicon_url = "https://github.com/"
    return "https://s2.googleusercontent.com/s2/favicons?domain_url=" + favicon_url

def _test_sourcery_thing1():
    # works as expected
    # difference from original is the name of the variable
    url = "https://github.com/"
    return "https://s2.googleusercontent.com/s2/favicons?domain_url=" + url

def _test_sourcery_thing2():
    # works as expected 
    # difference from original is both strings are empty
    favicon_url = ""
    return "" + favicon_url

Hope this helps!

Sourcery Version

v0.11.2

Code editor or IDE name and version

Pycharm v?

OS name and version

Version: 1.66.0 (user setup)
Commit: e18005f0f1b33c29e81d732535d8c0e47cafb0b5
Date: 2022-03-30T05:50:14.623Z
Electron: 17.2.0
Chromium: 98.0.4758.109
Node.js: 16.13.0
V8: 9.8.177.11-electron.0
OS: Windows_NT x64 10.0.22593

@diceroll123
Copy link
Author

That all said, the return line in the final method turns into return f"{favicon_url}" which is redundant. Could be another refactoring option, maybe? 😉

@ruancomelli
Copy link
Contributor

Hi, @diceroll123, thank you for this submitting this bug report! Keep them coming 😁

I was able to reproduce this and will look into it. And yes, replacing f"{string}" with simply string is a great idea, I've added it to our roadmap.

@ruancomelli ruancomelli self-assigned this Apr 11, 2022
@ruancomelli ruancomelli added bug Something isn't working enhancement New feature or request labels Apr 11, 2022
@ruancomelli
Copy link
Contributor

Hi again! I just added a fix for the issue you reported - it'll be available in the next Sourcery release.

@ruancomelli ruancomelli added the next release This will be fixed in next release label Apr 14, 2022
@Hellebore
Copy link
Collaborator

Fixed in 0.11.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request next release This will be fixed in next release
Projects
None yet
Development

No branches or pull requests

3 participants