Test Failed
Pull Request — master (#50)
by
unknown
01:52
created

LocalizedIntegerField.from_db_value()   B

Complexity

Conditions 5

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 5.2

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 15
rs 8.5454
ccs 8
cts 10
cp 0.8
cc 5
crap 5.2
1 1
from django.conf import settings
0 ignored issues
show
Configuration introduced by
The import django.conf could not be resolved.

This can be caused by one of the following:

1. Missing Dependencies

This error could indicate a configuration issue of Pylint. Make sure that your libraries are available by adding the necessary commands.

# .scrutinizer.yml
before_commands:
    - sudo pip install abc # Python2
    - sudo pip3 install abc # Python3
Tip: We are currently not using virtualenv to run pylint, when installing your modules make sure to use the command for the correct version.

2. Missing __init__.py files

This error could also result from missing __init__.py files in your module folders. Make sure that you place one file in each sub-folder.

Loading history...
2
3 1
from .field import LocalizedField
4
5 1
class LocalizedIntegerField(LocalizedField):
6
7 1
    @classmethod
8
    def from_db_value(cls, value, *_):
9
10 1
        if isinstance(value, dict):
11 1
            values = LocalizedField.from_db_value(value, *_)
12 1
            converted_values = {}
13
14 1
            for lang_code, _ in settings.LANGUAGES:
15 1
                value = values.get(lang_code)
16 1
                converted_values[lang_code] = int(value) if value is not None else None
17
            
0 ignored issues
show
Coding Style introduced by
Trailing whitespace
Loading history...
18 1
            return cls.attr_class(converted_values)
19
20
        if not isinstance(value, dict):
21
            return int(value)
22