File core.py
has 7031 lines of code (exceeds 250 allowed). Consider refactoring. Open
""" Toolkit for modeling complex datasets with collections of user-friendly tables
Many classes contain the methods ``serialize()`` and `deserialize()``, which invert each other.
``serialize()`` converts a python object instance into a string representation, whereas
``deserialize()`` parses an object's string representation -- as would be stored in a file or spreadsheet
Function from_dict
has a Cognitive Complexity of 89 (exceeds 5 allowed). Consider refactoring. Open
def from_dict(json, models, decode_primary_objects=True, primary_objects=None, decoded=None, ignore_extra_models=False,
validate=False, output_format=None):
""" Decode a simple Python representation (dict, list, str, float, bool, None) of an object that
is compatible with JSON and YAML, including references to objects through :obj:`__id` keys.
- 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 validate_attr_tuples
has a Cognitive Complexity of 64 (exceeds 5 allowed). Consider refactoring. Open
def validate_attr_tuples(metacls, name, bases, namespace, meta_attribute_name):
""" Validate a tuple of tuples of attribute names
Args:
meta_attribute_name (:obj:`str`): the name of the attribute to validate and normalize
- 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
Model
has 62 functions (exceeds 20 allowed). Consider refactoring. Open
class Model(object, metaclass=ModelMeta):
""" Base object model
Attributes:
_source (:obj:`ModelSource`): file location, worksheet, column, and row where the object was defined
Function to_dict
has a Cognitive Complexity of 57 (exceeds 5 allowed). Consider refactoring. Open
def to_dict(object, models=None, encode_primary_objects=True, encoded=None):
""" Encode a instance of :obj:`Model` or a collection of instances of :obj:`Model` using a simple Python representation
(dict, list, str, float, bool, None) that is compatible with JSON and YAML. Use :obj:`__id` keys to avoid infinite recursion
by encoding each object once and referring to objects by their __id for each repeated reference.
- 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 difference
has a Cognitive Complexity of 47 (exceeds 5 allowed). Consider refactoring. Open
def difference(self, other, tol=0.):
""" Get the semantic difference between two models
Args:
other (:obj:`Model`): other :obj:`Model`
- 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 deserialize_from_cell
has a Cognitive Complexity of 46 (exceeds 5 allowed). Consider refactoring. Open
def deserialize_from_cell(self, values, objects, decoded=None):
""" Deserialize value from cell
Args:
values (:obj:`str`): String representation
- 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 _tree_str
has a Cognitive Complexity of 44 (exceeds 5 allowed). Consider refactoring. Open
def _tree_str(self, printed_objs, depth, max_depth):
""" Obtain a nested list of string representations of this Model.
Follows the graph of related :obj:`Model`'s up to a depth of :obj:`max_depth`. Called recursively.
- 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 _render_difference
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def _render_difference(self, difference):
""" Generate string representation of difference data structure
Args:
difference (:obj:`dict`): representation of the semantic difference between two objects
- 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_difference
has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring. Open
def _simplify_difference(self, difference):
""" Simplify difference data structure
Args:
difference (:obj:`dict`): representation of the semantic difference between two objects
- 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 get_xlsx_validation
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
""" Get XLSX validation
Args:
sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
- 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 validate_related_attributes
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def validate_related_attributes(metacls, name, bases, namespace):
""" Check the related attributes
Raises:
:obj:`ValueError`: if an :obj:`OneToManyAttribute` or :obj:`ManyToOneAttribute` has a :obj:`related_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 is_equal
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def is_equal(self, other, tol=0.):
""" Determine whether two models are semantically equal
Args:
other (:obj:`Model`): object to compare
- 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 are_related_attributes_serializable
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def are_related_attributes_serializable(cls):
""" Determine if the immediate related attributes of the class can be serialized
Returns:
:obj:`bool`: :obj:`True` if the related attributes can be serialized
- 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 get_xlsx_validation
has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring. Open
def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
""" Get XLSX validation
Args:
sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
- 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 validate_unique
has a Cognitive Complexity of 31 (exceeds 5 allowed). Consider refactoring. Open
def validate_unique(cls, objects):
""" Validate attribute uniqueness
Args:
objects (:obj:`list` of :obj:`Model`): list of objects
- 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 normalize
has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring. Open
def normalize(self):
""" Normalize an object into a canonical form. Specifically, this method sorts the RelatedManagers
into a canonical order because their order has no semantic meaning. Importantly, this canonical form
is reproducible. Thus, this canonical form facilitates reproducible computations on top of :obj:`Model`
objects.
- 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 index
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def index(self, *args, **kwargs):
""" Get related object index by attribute/value pairs
Args:
*args (:obj:`Model`): object to find
- 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 is_serializable
has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring. Open
def is_serializable(cls):
""" Determine if the class (and its related classes) can be serialized
Raises:
:obj:`bool`: :obj:`True` if the class can be serialized
- 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 serialize_to_cell
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def serialize_to_cell(self, values, encoded=None):
""" Serialize related object
Args:
values (:obj:`list` of :obj:`Model`): Python representation
- 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 are_attr_paths_equal
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def are_attr_paths_equal(cls, attr_path, other_attr_path):
""" Determine if two attribute paths are semantically equal
Args:
attr_path (:obj:`list` of :obj:`list` of :obj:`object`):
- 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 get_related
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def get_related(self, forward=True, reverse=True):
""" Get all related objects reachable from :obj:`self`
Args:
forward (:obj:`bool`, optional): if :obj:`True`, get all forward related objects
- 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 _generate_normalize_sort_key_all_attrs
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring. Open
def _generate_normalize_sort_key_all_attrs(cls, processed_models=None):
""" Generate a key for sorting models by all of their attributes into a normalized order. This method should
be used for models which do not have unique attributes or sets of unique attributes.
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 deserialize
has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring. Open
def deserialize(self, values, objects, decoded=None):
""" Deserialize value
Args:
values (:obj:`object`): String representation
- 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 init_related_attributes
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def init_related_attributes(cls, model_cls):
""" Initialize related attributes """
for attr in model_cls.Meta.attributes.values():
if isinstance(attr, RelatedAttribute):
- 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 deserialize
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def deserialize(self, values, objects, decoded=None):
""" Deserialize value
Args:
values (:obj:`object`): String representation
- 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 cut_relations
has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring. Open
def cut_relations(self, objs_to_keep=None):
""" Cut relations to objects not in :obj:`objs`.
Args:
objs_to_keep (:obj:`set` of :obj:`Model`, optional): objects to retain relations to
- 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 __init__
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, enum_class, none=False, default=None, default_cleaned_value=None, none_value=None, verbose_name='', description='',
primary=False, unique=False, unique_case_insensitive=False):
"""
Args:
enum_class (:obj:`type` or :obj:`list`): subclass of :obj:`Enum`, :obj:`list` of enumerated names,
- 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 __new__
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def __new__(metacls, name, bases, namespace):
"""
Args:
metacls (:obj:`Model`): :obj:`Model`, or a subclass of :obj:`Model`
name (:obj:`str`): :obj:`Model` class 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 validate
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the attribute
Args:
obj (:obj:`Model`): object being validated
- 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 get_xlsx_validation
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
""" Get XLSX validation
Args:
sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
- 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 get_xlsx_validation
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
""" Get XLSX validation
Args:
sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
- 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
Manager
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
class Manager(object):
""" Enable O(1) dictionary-based searching of a Model's instances
This class is inspired by Django's :obj:`Manager` class. An instance of :obj:`Manger` is associated with
each :obj:`Model` and accessed as the class attribute :obj:`objects` (as in Django).
Function copy
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def copy(self):
""" Create a copy
Returns:
:obj:`Model`: model copy
- 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 validate_attributes
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def validate_attributes(metacls, name, bases, namespace):
""" Validate attribute values
Raises:
:obj:`ValueError`: if attributes are not valid
- 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 is_equal
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
def is_equal(self, other, tol=0.):
if self.__class__ != other.__class__:
return False
min_eq = self.min.__class__ == other.min.__class__ and (
- 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 _is_equal_attributes
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def _is_equal_attributes(self, other, tol=0.):
""" Determine if the attributes of two objects are semantically equal
Args:
other (:obj:`Model`): object to compare
- 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 get_xlsx_validation
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
""" Get XLSX validation
Args:
sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
- 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 _generate_normalize_sort_keys
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def _generate_normalize_sort_keys(cls):
""" Generates keys for sorting the class """
generated_keys = []
keys_to_generate = [cls]
while keys_to_generate:
- 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 __init__
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, _comments=None, **kwargs):
"""
Args:
**kwargs: dictionary of keyword arguments with keys equal to the names of the model attributes
- 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
Consider simplifying this complex logical expression. Open
if (include is None or (value in include or
(include_nan
and (isinstance(value, numbers.Number)
and isnan(value))))) and \
(exclude is None or (value not in exclude
Function __init__
has 16 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, related_class, related_name='', default=list(), default_cleaned_value=list(),
Consider simplifying this complex logical expression. Open
if (callable(default) or
(isinstance(default, list) and len(default) > 0) or
(not isinstance(default, list) and default is not None)) and \
(callable(related_default) or
(isinstance(related_default, list) and len(related_default) > 0) or
Function related_validate
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def related_validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the related attribute
Args:
obj (:obj:`Model`): object being validated
- 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 clean
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def clean(self, value):
""" Convert attribute value into the appropriate type
Args:
value (:obj:`object`): value of attribute to clean
- 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 related_validate
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def related_validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the related attribute
Args:
obj (:obj:`Model`): object being validated
- 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 get_xlsx_validation
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
""" Get XLSX validation
Args:
sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
- 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 deserialize
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def deserialize(self, value, objects, decoded=None):
""" Deserialize value
Args:
value (:obj:`str`): String representation
- 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 related_validate
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
def related_validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the related attribute
Args:
obj (:obj:`Model`): object being validated
- 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 __init__
has 15 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, related_class, related_name='', default=list(), default_cleaned_value=list(),
Function __init__
has 15 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, related_class, related_name='',
Function validate
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the attribute
Args:
obj (:obj:`Model`): object being validated
- 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 get_children
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_children(self, kind=None, __type=None, recursive=True, **kwargs):
""" Get a kind of children.
If :obj:`kind` is :obj:`None`, children are defined to be the values of the related attributes defined
in each class.
- 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 deserialize
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def deserialize(self, value, objects, decoded=None):
""" Deserialize value
Args:
value (:obj:`str`): String representation
- 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 get_nested_attr
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_nested_attr(cls, attr_path):
""" Get the value of an attribute or a nested attribute of a model
Args:
attr_path (:obj:`list` of :obj:`list` of :obj:`str`):
- 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 clean
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def clean(self, value):
""" Convert attribute value into the appropriate type
Args:
value (:obj:`object`): value of attribute to clean
- 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 clean
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def clean(self, value):
""" Convert attribute value into the appropriate type
Args:
value (:obj:`object`): value of attribute to clean
- 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 get_models
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def get_models(module=None, inline=True):
""" Get models
Args:
module (:obj:`module`, optional): module
- 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 validate
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, objects):
""" Validate a list of objects and return their errors
Args:
object (:obj:`list` of :obj:`Model`): list of Model instances
- 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 __init__
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, related_class, related_name='',
Function get_immediate_children
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def get_immediate_children(self, kind=None, __type=None, **kwargs):
""" Get a kind of immediate children
If :obj:`kind` is :obj:`None`, children are defined to be the values of the related attributes defined
in each class.
- 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 __init__
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, related_class, related_name='',
init_value=None, default=None, default_cleaned_value=None, none_value=None,
related_init_value=None, related_default=None,
min_related=0, max_related=float('inf'), min_related_rev=0, max_related_rev=float('inf'),
verbose_name='', verbose_related_name='', description=''):
- 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 validate
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the attribute
Args:
obj (:obj:`Model`): object being validated
- 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 init_attributes
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
def init_attributes(cls):
""" Initialize attributes """
cls.Meta.attributes = collections.OrderedDict()
for attr_name in sorted(dir(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 __init__
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, pattern, flags=0, min_length=0, max_length=None,
Function validate
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the attribute
Args:
obj (:obj:`Model`): object being validated
- 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 validate_attribute_inheritance
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def validate_attribute_inheritance(metacls, name, bases, namespace):
""" Check attribute inheritance
Raises:
:obj:`ValueError`: if subclass overrides a superclass attribute (instance of Attribute) with an incompatible
- 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 clean
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def clean(self, value):
""" Convert attribute value into the appropriate type
Args:
value (:obj:`object`): value of attribute to clean
- 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 get_attrs_by_val
has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring. Open
def get_attrs_by_val(self, type=None, reverse=True,
include=None, exclude=None):
""" Get attributes whose type is :obj:`type` and values are
in :obj:`include` and not :obj:`exclude`, optionally including attributes
from related classes. By default, get all attributes.
- 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 __init__
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, min_length=0, max_length=255, none=False, default='', default_cleaned_value='', none_value='',
Function __init__
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, min_length=0, max_length=2**32 - 1, none=False, default='', default_cleaned_value='', none_value='',
Function __init__
has 11 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, related_class, related_name='',
Function __init__
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, enum_class, none=False, default=None, default_cleaned_value=None, none_value=None, verbose_name='', description='',
Function gen_merge_map
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def gen_merge_map(self, other):
""" Create a dictionary that maps instances of objects in another model to objects
in a model
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 __init__
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, min=float('nan'), max=float('nan'), nan=True,
Function __init__
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, min=None, max=None, none=False, default=None, default_cleaned_value=None,
Function get_xlsx_validation
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
""" Get XLSX validation
Args:
sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
- 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 validate
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the attribute
Args:
obj (:obj:`Model`): object being validated
- 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 get_xlsx_validation
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
""" Get XLSX validation
Args:
sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
- 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 validate
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, obj, value):
""" Determine if :obj:`value` is a valid value for this StringAttribute
Args:
obj (:obj:`Model`): class being validated
- 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 __init__
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, max=None, none=False, default=None, default_cleaned_value=None,
Function __init__
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, init_value=None, default=None, default_cleaned_value=None, none_value=None, verbose_name='', description='',
Function __init__
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, max=float('nan'), nan=True, default=float('nan'), default_cleaned_value=float('nan'),
Function get_all_related
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def get_all_related(objs, forward=True, reverse=True):
""" Optimally obtain all objects related to objects in :obj:`objs`
The set of all :obj:`Model`\ s can be viewed as a graph whose nodes are :obj:`Model` instances
and whose edges are related connections. Because related edges are bi-directional, this graph
- 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 validate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the attribute
Args:
obj (:obj:`Model`): object being validated
- 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 validate
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def validate(self):
""" Determine if the object is valid
Returns:
:obj:`InvalidObject` or None: :obj:`None` if the object is valid,
- 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 has_attr_vals
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def has_attr_vals(self, __type=None, __check_attr_defined=True, **kwargs):
""" Check if the type and values of the attributes of an object match a set of conditions
Args:
__type (:obj:`types.TypeType` or :obj:`tuple` of :obj:`types.TypeType`): subclass(es) of :obj:`Model`
- 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 __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, none=True, default=None, default_cleaned_value=None, none_value=None,
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, verbose_name='', description='Enter a path to a local file or directory',
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, type=float, separator='-', separator_pattern=r'(?<!e) *- *',
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, none=True, default=None, default_cleaned_value=None, none_value=None,
Function from_dict
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def from_dict(json, models, decode_primary_objects=True, primary_objects=None, decoded=None, ignore_extra_models=False,
Function __init__
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, none=True, default=None, default_cleaned_value=None, none_value=None,
Consider simplifying this complex logical expression. Open
if isinstance(attr, (
OneToOneAttribute,
OneToManyAttribute,
ManyToOneAttribute,
ManyToManyAttribute)) and \
Function set_nested_attr_val
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def set_nested_attr_val(self, attr_path, value):
""" Set the value of an attribute or a nested attribute of a model
Args:
attr_path (:obj:`list` of :obj:`list` of :obj:`object`):
- 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 validate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the attribute
Args:
obj (:obj:`Model`): object being validated
- 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 get_xlsx_validation
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
""" Get XLSX validation
Args:
sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
- 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 __init__
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, min_length=0, max_length=255, none=False, default='', default_cleaned_value='', none_value='',
verbose_name='', description='',
primary=False, unique=False, unique_case_insensitive=False):
"""
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 related_validate
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def related_validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the related attribute
Args:
obj (:obj:`Model`): object being validated
- 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 set_value
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def set_value(self, obj, new_value):
""" Update the values of the related attributes of the attribute
Args:
obj (:obj:`object`): object whose attribute should be set
- 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 split_separated_list
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def split_separated_list(joined_values, separator=','):
""" Parse a separator list of values into a list of values
Args:
joined_values (:obj:`str`): seperator-separated list of values
- 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 validate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the attribute
Args:
obj (:obj:`Model`): object being validated
- 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 set_source
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def set_source(self, path_name, sheet_name, attribute_seq, row, table_id=None):
Function __init__
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, min=None, max=None, none=False, default=None, default_cleaned_value=None,
none_value=None, verbose_name='', description='', primary=False, unique=False):
"""
Args:
min (:obj:`int`, optional): minimum value
- 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 __init__
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, type=str, separator=',', default=[], none_value=[], verbose_name='',
Function set_related_value
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def set_related_value(self, obj, new_value):
""" Update the values of the related attributes of the attribute
Args:
obj (:obj:`object`): object whose attribute should be set
- 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 merge
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def merge(self, other, normalize=True, validate=True):
""" Merge another model into a model
Args:
other (:obj:`Model`): other model
- 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 get_xlsx_validation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
""" Get XLSX validation
Args:
sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
- 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 get_xlsx_validation
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
""" Get XLSX validation
Args:
sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
- 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 validate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the attribute
Args:
obj (:obj:`Model`): object being validated
- 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 clean
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def clean(self, value):
""" Convert attribute value into the appropriate type
Args:
value (:obj:`object`): value of attribute to clean
- 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 validate
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, obj, value):
""" Determine if :obj:`value` is a valid value
Args:
obj (:obj:`Model`): class being validated
- 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
Avoid deeply nested control flow statements. Open
if '.' not in related_class_name:
related_class_name = model.__module__ + '.' + related_class_name
else:
Avoid deeply nested control flow statements. Open
if isinstance(attr, (
OneToOneAttribute,
OneToManyAttribute,
ManyToOneAttribute,
ManyToManyAttribute)) and \
Avoid deeply nested control flow statements. Open
if isinstance(val, list):
objs_to_normalize.extend(val)
elif val:
objs_to_normalize.append(val)
Avoid deeply nested control flow statements. Open
for i_val2 in range(i_val, len(val)):
difference['attributes'][attr_name].append(
'No matching element {}'.format(serial_vals[i_val2][0]))
elif val is None:
Avoid deeply nested control flow statements. Open
if new_to_msg:
msg += prefix + new_to_msg
prefix = ''
Avoid deeply nested control flow statements. Open
if v:
if isinstance(v, dict):
new_to_flatten.append(diff_hierarchy + [v])
else:
val.remove(v)
Avoid deeply nested control flow statements. Open
if attr_name in cls.Meta.attributes:
other_cls = attr.related_class
else:
other_cls = attr.primary_class
Avoid deeply nested control flow statements. Open
if attr_name not in Meta.attribute_order:
Meta.attribute_order.append(attr_name)
Meta.attribute_order = tuple(Meta.attribute_order)
Avoid deeply nested control flow statements. Open
if v not in objs_to_keep:
val.remove(v)
else:
Avoid deeply nested control flow statements. Open
if '__module__' in namespace and related_class_name == namespace['__module__'] + '.' + name:
attribute_names.append(attr.related_name)
else:
for base in bases:
if related_class_name == base.__module__ + '.' + base.__name__:
Avoid deeply nested control flow statements. Open
if new_to_render:
new_to_render[0][2] = prefix + new_to_render[0][2]
new_to_render.reverse()
to_render.extend(new_to_render)
else:
Avoid deeply nested control flow statements. Open
if attr_json is None:
attr_val = None
elif isinstance(attr_json, list):
attr_val = []
Avoid deeply nested control flow statements. Open
for oo in getattr(o, attr_name):
objs[attr.related_class][oo.serialize()] = oo
Avoid deeply nested control flow statements. Open
if metacls.CHECK_SAME_RELATED_ATTRIBUTE_NAME and \
attr.related_name in related_class.Meta.related_attributes and \
related_class.Meta.related_attributes[attr.related_name] is not attr:
other_attr = related_class.Meta.related_attributes[
attr.related_name]
Avoid deeply nested control flow statements. Open
if val.__class__ != other_val.__class__:
return False
Avoid deeply nested control flow statements. Open
if attr.is_related_to_many:
getattr(existing_deserialized_value, attr.name).extend(getattr(deserialized_value, attr.name, []))
setattr(deserialized_value, attr.name, [])
elif attr.is_related:
related_val = getattr(deserialized_value, attr.name)
Avoid deeply nested control flow statements. Open
if isinstance(val, list) and len(val) > 1:
if attr_name in obj.Meta.attributes:
cls = attr.related_class
else:
cls = attr.primary_class
Avoid deeply nested control flow statements. Open
if isinstance(attr, RelatedAttribute):
if val is None:
json_val = None
elif isinstance(val, list):
json_val = []
Avoid deeply nested control flow statements. Open
while i_val < len(val) and oi_val < len(other_val):
serial_v = serial_vals[i_val][0]
serial_ov = serial_other_vals[oi_val][0]
if serial_v == serial_ov:
el_diff = {}
Avoid deeply nested control flow statements. Open
if isinstance(value, list):
objs_to_explore.extend(value)
elif value is not None:
objs_to_explore.append(value)
Avoid deeply nested control flow statements. Open
if v not in printed_objs:
iter_attr.append(v._tree_str(
printed_objs, depth + 1, max_depth))
attrs.extend(iter_attr)
Avoid deeply nested control flow statements. Open
if attr.related_name in related_class.Meta.attributes and \
not (isinstance(attr, (OneToOneAttribute, ManyToManyAttribute)) and attr.related_name == attr_name):
other_attr = related_class.Meta.attributes[
attr.related_name]
raise ValueError('Related attribute {}.{} cannot use the same related name as {}.{}'.format(
Avoid deeply nested control flow statements. Open
if val is None:
pass
elif isinstance(val, Model):
pairs_to_check.append((val, other_val, ))
elif len(val) != len(other_val):
Avoid deeply nested control flow statements. Open
for i_el, el_diff in enumerate(difference['attributes'][attr_name]):
if isinstance(el_diff, dict):
el_prefix = '\n{}element: {}: "{}" != element: {}: "{}"'.format(
' ' * 2 * (indent + 2),
el_diff['objects'][0].__class__.__name__,
Function get_attrs_by_val
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_attrs_by_val(self, type=None, reverse=True,
Function add_to_decoding_queue
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def add_to_decoding_queue(json, models_by_name=models_by_name, decoded=decoded, to_decode=to_decode,
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, path_name, sheet_name, attribute_seq, row, table_id=None):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, attribute, messages, related=False, location=None, value=None):
Function get_children
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_children(self, kind=None, __type=None, recursive=True, **kwargs):
Function __init__
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def __init__(self, default=False, default_cleaned_value=None, none_value=None, verbose_name='', description='Enter a Boolean value'):
Function __init__
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, attr, primary_class, is_primary=True):
"""
Args:
attr (:obj:`Attribute`): attribute
primary_class (:obj:`type`): class in which :obj:`attr` was defined
- 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 validate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the attribute
Args:
obj (:obj:`Model`): object being validated
- 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 _get_attribute_types
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _get_attribute_types(self, model_obj, attr_names):
""" Provide the attribute types for a tuple of attribute names
Args:
model_obj (:obj:`Model`): a :obj:`Model` instance
- 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 create
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def create(self, __type=None, **kwargs):
""" Create instance of primary class and add to list
Args:
__type (:obj:`types.TypeType` or :obj:`tuple` of :obj:`types.TypeType`): subclass(es) of :obj:`Model`
- 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 sort
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def sort(cls, objects):
""" Sort list of :obj:`Model` objects
Args:
objects (:obj:`list` of :obj:`Model`): list of objects
- 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 get_xlsx_validation
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
""" Get XLSX validation
Args:
sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
- 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 _get_tabular_schema_format
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _get_tabular_schema_format(self):
""" Generate a string which represents the format of the attribute for use
in tabular-formatted schemas
Returns:
- 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 clean
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def clean(self, value):
""" Deserialize value
Args:
value (:obj:`str`): semantically equivalent representation
- 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 get_xlsx_validation
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def get_xlsx_validation(self, sheet_models=None, doc_metadata_model=None):
""" Get XLSX validation
Args:
sheet_models (:obj:`list` of :obj:`Model`, optional): models encoded as separate sheets
- 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 _get_hashable_values
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _get_hashable_values(values):
""" Provide hashable values for a tuple of values of a :obj:`Model`'s attributes
Args:
values (:obj:`tuple`): values of :obj:`Model` attributes
- 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 _generate_normalize_sort_key_unique_together
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _generate_normalize_sort_key_unique_together(cls, processed_models=None):
""" Generate a key for sorting models by their shortest set of unique attributes into a normalized order
Args:
processed_models (:obj:`list`, optional): list of models for which sort keys have already been generated
- 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 set_value
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def set_value(self, obj, new_value):
""" Update the values of the related attributes of the attribute
Args:
obj (:obj:`object`): object whose attribute should be set
- 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 validate_unique
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def validate_unique(self, objects, values):
""" Determine if the attribute values are unique
Args:
objects (:obj:`list` of :obj:`Model`): list of :obj:`Model` objects
- 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
Avoid too many return
statements within this function. Open
return (datetime_value.date(), None)
Avoid too many return
statements within this function. Open
return False
Avoid too many return
statements within this function. Open
return (value, InvalidAttribute(self, ['String must be a valid date']))
Avoid too many return
statements within this function. Open
return (value, InvalidAttribute(self, ['Value must be an instance of `datetime`']))
Avoid too many return
statements within this function. Open
return (value, InvalidAttribute(self, ['Value must be an instance of `date`']))
Avoid too many return
statements within this function. Open
return (time(hour, minutes, seconds), None)
Avoid too many return
statements within this function. Open
return False
Avoid too many return
statements within this function. Open
return (None, InvalidAttribute(self, ['Multiple matching objects with primary attribute = {}'.format(value)]))
Avoid too many return
statements within this function. Open
return (value, InvalidAttribute(self, ['Time must be 0:0:0.0']))
Avoid too many return
statements within this function. Open
return (value, InvalidAttribute(self, ['Number must be a valid time']))
Avoid too many return
statements within this function. Open
return (None, InvalidAttribute(self, ['Unable to deserialize an instance of {}'.format(value.__class__.__name__)]))
Avoid too many return
statements within this function. Open
return (None, InvalidAttribute(self, ['Unable to deserialize an instance of {}'.format(value.__class__.__name__)]))
Avoid too many return
statements within this function. Open
return (date.fromordinal(int_value + date(1900, 1, 1).toordinal() - 1), None)
Avoid too many return
statements within this function. Open
return (value, InvalidAttribute(self, ['String must be a valid time']))
Avoid too many return
statements within this function. Open
return (value, InvalidAttribute(self, ['Value must be an instance of `time`']))
Avoid too many return
statements within this function. Open
return False
Avoid too many return
statements within this function. Open
return (value, InvalidAttribute(self, ['String must be a valid datetime']))
Avoid too many return
statements within this function. Open
return True
Avoid too many return
statements within this function. Open
return (None, InvalidAttribute(self, ['Multiple matching objects with primary attribute = {}'.format(value)]))
Avoid too many return
statements within this function. Open
return (datetime.combine(date_value, time_value), None)
Avoid too many return
statements within this function. Open
return True
Function _dump_index_dicts
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _dump_index_dicts(self, file=None):
""" Dump the index dictionaries for debugging
Args:
file (:obj:`object`, optitonal): an object with a :obj:`write(string)` method
- 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 clean
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def clean(self, value):
""" Deserialize value
Args:
value (:obj:`str`): semantically equivalent representation
- 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 validate
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def validate(self, obj, value):
""" Determine if :obj:`value` is a valid value of the attribute
Args:
obj (:obj:`Model`): object being validated
- 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 _gc_weaksets
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _gc_weaksets(self):
""" Garbage collect empty WeakSets formed by deletion of weak refs to :obj:`Model` instances with no strong refs
Returns:
:obj:`int`: number of empty WeakSets deleted
- 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 __init__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __init__(self, min=float('nan'), max=float('nan'), nan=True,
default=float('nan'), default_cleaned_value=float('nan'), none_value=float('nan'), verbose_name='', description='',
primary=False, unique=False):
"""
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 value_equal
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def value_equal(self, val1, val2, tol=0.):
""" Determine if attribute values are equal, optionally,
up to a tolerance
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 _parse_attr_path_el
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _parse_attr_path_el(cls, attr):
""" Parse an element of a path to a nested attribute
Args:
attr (:obj:`list` of :obj:`dict`): an element of a path to a nested attribute
- 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 _delete
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def _delete(self, model_obj):
""" Delete an :obj:`model_obj` from the indices
Args:
model_obj (:obj:`Model`): a :obj:`Model` instance
- 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"