Function partition
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
def partition(
key: Union[int, Pred], seq: Seq, sep: bool = False
) -> Union[Tuple[Seq, Seq], Tuple[list, list, Seq]]:
"""
Partition sequence in two.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function _chunks_sizes_ex
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def _chunks_sizes_ex(ns, seq, drop, pad):
buf = []
clear = buf.clear
fill = buf.extend
seq = iter(seq)
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function chunks
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def chunks(
n: Union[int, Iterable[int]], seq: Seq[T], *, pad=NOT_GIVEN, drop: bool = False
) -> Iter[Tuple[T, ...]]:
"""
Partition sequence into non-overlapping tuples of length n.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Function chunks
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def chunks(
Avoid too many return
statements within this function. Open
return Iter(_chunks_split(func, seq))
Avoid too many return
statements within this function. Open
return Iter(_chunks_sizes_ex(n, seq, False, pad))
Avoid too many return
statements within this function. Open
return Iter(_chunks_sizes(n, seq))
Function chunks_by
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def chunks_by(func: Func, seq: Seq, how: ChunksHow = "values") -> Iter:
"""
Partition sequence into chunks according to a function.
It creates a new partition every time the value of func(item) changes.
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"