pincer.utils.replace.replace()   A
last analyzed

Complexity

Conditions 2

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
nop 3
1
# Copyright Pincer 2021-Present
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
from typing import Any, Callable, Iterable, List, T
5
6
7
def replace(
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
8
    func: Callable[[Any], bool], iter_: Iterable[T], new_item: T
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
9
) -> List[T]:
10
    return [item if func(item) else new_item for item in iter_]
11