Showing 18 of 163 total issues
Function __new__
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def __new__(mcs, name, bases, namespace, **kwargs):
if kwargs.get('__base_definition__', False):
kwargs.pop('__base_definition__')
mcs.__root__ = super().__new__(mcs, name, bases, namespace, **kwargs)
return mcs.__root__
- 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 _transform_to_class_methods
has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring. Open
def _transform_to_class_methods(cls):
metaclass = type(cls)
mro = inspect.getmro(cls)
ignore = {'__class__', '__dict__', '__bases__', '__name__', '__qualname__',
'__mro__', '__subclasses__', '__init_subclass__', '__subclasshook__',
- 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 type_field
has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring. Open
def type_field(field_name, position: Position = Position.INSIDE, allow_reregistration=False):
"""Class decorator for polymorphic hierarchies to define class field name, where subclass's type alias will be stored
Use it on hierarchy root class, add class field with defined name to any subclasses
The same field name will be used during deserialization
- 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 16 (exceeds 5 allowed). Consider refactoring. Open
def deserialize(obj, as_class: SerializerType):
"""Convert python dict into given class
:param obj: dict (or list or any primitive) to deserialize
:param as_class: type or serializer
- 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 make_string
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
def make_string(*fields: str, include_name=True):
"""
Decorator to create a `__str__` method for class based on `__init__` arguments
Usage: directly :func:`@make_string` on class declaration to include all fields
- 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 _construct_from_dict
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def _construct_from_dict(obj, as_class):
kwargs = {}
for f in get_class_fields(as_class):
name = f.name
field_type = _get_field_type(f, obj)
- 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
has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring. Open
def serialize(obj, as_class: SerializerType = None):
"""
Convert object into JSON-compatible dict (or other structure)
:param obj: object to serialize
- 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_defining_class
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _get_defining_class(cls, method, method_name=None, mro=None, stop_class=None):
mro = mro or inspect.getmro(cls)
method_name = method_name or method.__name__
for parent in mro:
m = parent.__dict__.get(method_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 _serialize_to_dict
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _serialize_to_dict(cls, obj):
result = {}
fields = get_class_fields(cls)
for f in fields:
name = f.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 _construct_from_list
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
def _construct_from_list(obj, as_class):
args = []
if type_field_position_is(as_class, Position.INSIDE):
obj = obj[1:]
for i, f in enumerate(get_class_fields(as_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 get_type_name_repr
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
def get_type_name_repr(cls):
if is_generic(cls):
typename = getattr(cls, '_name', str(cls.__origin__))
if typename.startswith('typing.'):
typename = typename[len('typing.'):]
- 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 _argspec_to_fields
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _argspec_to_fields(f, arguments, defaults, hints, types_required=True) -> typing.List[Field]:
Function _get_defining_class
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def _get_defining_class(cls, method, method_name=None, mro=None, stop_class=None):
Function _construct_object
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _construct_object(obj, as_class: Type):
if isinstance(as_class, Hashable) and as_class in SERIALIZER_MAPPING:
as_class = SERIALIZER_MAPPING[as_class]
if issubclass(as_class, StaticSerializer):
- 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 _argspec_to_fields
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
def _argspec_to_fields(f, arguments, defaults, hints, types_required=True) -> typing.List[Field]:
defaults_num = len(defaults) if defaults is not None else 0
non_defaults_num = len(arguments) - defaults_num
fields = []
for i, arg in enumerate(arguments):
- 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 _serialize_as_type(obj, as_class)
Avoid too many return
statements within this function. Open
return seq_type([deserialize(o, seq_int_type) for o in obj])
Function __new__
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
def __new__(cls, **kwargs):
has_init = issubclass(_get_defining_class(cls, cls.__init__), Serializer)
if getattr(cls, '_dynamic', False):
if has_init:
cls.__init__(cls, **kwargs)
- 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"