danielgatis / rembg

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

Simplify Boolean Expressions Using `startswith` and `endswith` #594

Closed pixeeai closed 7 months ago

pixeeai commented 7 months ago

Many developers are not necessarily aware that the startswith and endswith methods of str objects can accept a tuple of strings to match. This means that there is a lot of code that uses boolean expressions such as x.startswith('foo') or x.startswith('bar') instead of the simpler expression x.startswith(('foo', 'bar')).

This codemod simplifies the boolean expressions where possible which leads to cleaner and more concise code.

The changes from this codemod look like this:

  x = 'foo'
- if x.startswith("foo") or x.startswith("bar"):
+ if x.startswith(("foo", "bar")):
     ...

Powered by: pixeebot (codemod ID: pixee:python/combine-startswith-endswith)

megga-dismas commented 7 months ago

I have learnt this today. Thanks!

danielgatis commented 7 months ago

People, I will reject this PR because this file is auto-generated.

citizenjosh commented 7 months ago

Is it a useful auto-generated improvement? @danielgatis

People, I will reject this PR because this file is auto-generated.

danielgatis commented 7 months ago

@citizenjosh the versioneer.py is an auto-generated file by this package: https://github.com/python-versioneer/python-versioneer