sourcery-ai / sourcery

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

Prompts to use-named-expression in Python v3.7 #268

Closed x-N0 closed 2 years ago

x-N0 commented 2 years ago

Issue description or question

I'm running Python 3.7.9 and I have a line of code like this:

mom = get_mom()
if mom:
    print(f"{mom}'s here!")

And it's prompting with the message ("Use named expression to simplify assignment and conditional (use-named-expression)") to refactor using walrus operator as:

if mom:=get_mom():
    print(f"{mom}'s here!")

Walrus was added at v3.8.

Sourcery Version

0.12.7

Code editor or IDE name and version

Pycharm: 2021.2.2

OS name and version

Linux on Linux 5.10.136-1

bm424 commented 2 years ago

Hi @x-N0, thanks for raising the issue. We have instructions for this specific situation in the sourcery docs - check them out here. I'll close the issue for now, but if you're still having problems feel free to re-open.