danielgatis / rembg

Rembg is a tool to remove images background
MIT License
16.46k stars 1.84k forks source link

Use Assignment Expression (Walrus) In Conditional #601

Closed pixeeai closed 6 months ago

pixeeai commented 7 months ago

This codemod updates places where two separate statements involving an assignment and conditional can be replaced with a single Assignment Expression (commonly known as the walrus operator).

Many developers use this operator in new code that they write but don't have the time to find and update every place in existing code. So we do it for you! We believe this leads to more concise and readable code.

The changes from this codemod look like this:

- x = foo()
- if x is not None:
+ if (x := foo()) is not None:
      print(x)
More reading * [https://docs.python.org/3/whatsnew/3.8.html#assignment-expressions](https://docs.python.org/3/whatsnew/3.8.html#assignment-expressions)

Powered by: pixeebot (codemod ID: pixee:python/use-walrus-if)

pixeeai commented 6 months ago

@danielgatis any thoughts about this change request?

danielgatis commented 6 months ago

@pixeeai

I think it is good.

But the files:

Are automatically generated, so we should not change it.

pixeeai commented 6 months ago

We will check with the maintainer for those generated files, thanks!