sourcery icon indicating copy to clipboard operation
sourcery copied to clipboard

Case sensitive list converter as one-liner

Open Anselmoo opened this issue 1 year ago • 1 comments

Checklist

  • [x] I think this refactoring is useful for everyone (if it's too specific, consider a custom rule)
  • [x] I have checked there are no similar issues suggesting the same thing

Description

Sourcery already suggests dependencies as one-liners. There might be a new one for creating optional list

Code Before

In case you have work in your functions or class with iterators.

def example(func_name: str | list[str]):
      if isinstance(func_name, str):
            func_name = [func_name]

Code After

def example(func_name: str | list[str]):
      func_name = [func_name] if isinstance(func_name, str) else func_name

Anselmoo avatar Dec 29 '22 18:12 Anselmoo