flake8-simplify icon indicating copy to clipboard operation
flake8-simplify copied to clipboard

❄ A flake8 plugin that helps you to simplify code

Results 53 flake8-simplify issues
Sort by recently updated
recently updated
newest added

## Desired change * **Rule(s)**: SIM115 * **Adjustment**: Accept usage of contextlib.ExitStack ## Explanation In some applications, we may have a dynamic number of contextmanagers which we may choose to...

enhancement

Migrate to `pyproject.toml` using [`ini2toml`](https://pypi.org/project/ini2toml) to do the file conversion and running [`validate-pyproject`](https://github.com/abravalheri/validate-pyproject) to validate results. * Currently `flake8` is not yet compatible with `pyproject.toml` so move its config to...

## Explanation Use 'enumerate' to get a running number over an iterable. ## Example ```python # Bad idx = 0 for el in iterable: ... idx += 1 # Good...

enhancement

## Explanation SIM905 incorrectly identifies cases where [split is used with arguments](https://docs.python.org/3/library/stdtypes.html#str.split) ## Example This is an example where the mentioned rule(s) would currently be suboptimal: ```python from pprint import...

enhancement

The following case gets a SIM115 error, while it shouldn't. ```python file = '/path/to/file' with (open(file, 'rb') if file is not None else nullcontext(sys.stdin)) as fh: text = fh.read() ```

enhancement

Found via `codespell .`

## Explanation Using underscore on large number make for better comprehension. This feature was introduced with python 3.6 and [PEP515](https://peps.python.org/pep-0515/) describe it. ## Example ```python # Bad amount = 10000000.0...

enhancement

## Desired change * **Rule(s)**: SIM108, SIM118 * **Adjustment**: Cover casese, which are ignored for now ## Explanation For SIM118 package cannot handle any NotIn type of expressions, only In,...

enhancement

## Explanation Inspired by `if_same_then_else` rule in Rust Clippy. See https://rust-lang.github.io/rust-clippy/master/index.html#if_same_then_else. SIM114(#10) is similar, but it only checks if/elif, not if/else. ## Example ```python # Bad if a: b else:...

enhancement

Installed versions: ``` flake8==7.0.0 flake8-simplify==0.21.0 ``` Error: ``` $ flake8 multiprocessing.pool.RemoteTraceback: """ Traceback (most recent call last): File "C:\Program Files\Python311\Lib\multiprocessing\pool.py", line 125, in worker result = (True, func(*args, **kwds)) ^^^^^^^^^^^^^^^^^^^...