pincer.utils.replace   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 11
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A replace() 0 4 2
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