Showing 155 of 157 total issues
Function lazy_singledispatch
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def lazy_singledispatch(func): # noqa: C901
"""
Single-dispatch generic function decorator.
Transforms a function into a generic function, which can have different
- 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
fn
has 31 functions (exceeds 20 allowed). Consider refactoring. Open
class fn(mixins.FnMixin, metaclass=FunctionMeta):
"""
Base class for function-like objects in Sidekick.
"""
Function __getitem__
has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring. Open
def __getitem__(self, item, _chain=itertools.chain):
if isinstance(item, int):
if item >= 0:
head = []
for i, x in enumerate(self._iterator):
- 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 funcs
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def funcs(ret, arity=None, *, pure=True, accept_kwargs=True, diversity=50):
"""
Return random functions.
Args:
- 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 decompose
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def decompose(self):
"""
Return a namedtuple with the parts of function signature.
"""
- 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 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
L
has 24 functions (exceeds 20 allowed). Consider refactoring. Open
class L(DataMagic, type=list):
"""
Class for the L magic object.
"""
Function _casedispatch
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def _casedispatch(base, default_method=None):
registry = {}
cache = {}
def error(cls):
- 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 simplify_ast
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def simplify_ast(ast):
"""Deep AST simplification"""
if isinstance(ast, GetAttr):
attr, value = ast
- 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 shape_tree
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def shape_tree(max_depth, attrs, leaves):
mk_attrs = mk_random_attrs(attrs)
strategy = random.choice(["shallow", "deep", "random"])
root = Node(**mk_attrs())
- 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 unique
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def unique(seq: Seq, *, key: Func = None, exclude: Seq = (), slow=False) -> Iter:
"""
Returns the given sequence with duplicates removed.
Preserves order. If key is supplied map distinguishes values by comparing
- 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
Iter
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class Iter(Iterator[T]):
"""
Base sidekick iterator class.
This class extends classical Python iterators with a few extra operators.
Function op_wrapper_class
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def op_wrapper_class(
binary,
rbinary=None,
unary=None,
arithmetic=True,
- 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 from_namespace
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def from_namespace(base, namespace=None):
if namespace is None:
return lambda ns: from_namespace(base, ns)
if not base._UnionMeta__is_closed:
return SimpleNamespace(base=base, namespace=namespace, dispatch=...)
- 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 impure
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def impure(name, tt, ns, *, arity=None, flip=False):
method = getattr(tt, name)
if name in ns:
raise TypeError(f"function already registered: {name}")
- 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 peek
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def peek(self, steps=0, *, default=NOT_GIVEN):
"""
Peek next element without consuming iterator.
Pass the number of steps to check how many steps forward it will peek.
- 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 _from_sequence
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def _from_sequence(self, seq):
if len(seq) < 2:
raise ValueError("sequence must have at least 2 elements")
idx = seq.index(...)
- 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 _sibling
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def _sibling(self, delta):
if self._parent is not None:
siblings = self._parent.children
for idx, sibling in enumerate(siblings):
if self is sibling:
- 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 map_if
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def map_if(pred: Pred, func: Func, *seqs: Seq, index: Index = None) -> Iter:
"""
Applies func in the elements in which pred(elem) is True.
If more than one sequence is given, non-transformed elements are obtained
- 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 dedupe
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def dedupe(seq: Seq, *, key: Func = None) -> Iter:
"""
Remove duplicates of successive elements.
Args:
- 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"