1 | """Schema implementation based on JSONSchema v4 draft |
||
2 | """ |
||
3 | |||
4 | from __future__ import ( |
||
5 | absolute_import, |
||
6 | division, |
||
7 | print_function |
||
8 | ) |
||
9 | |||
10 | import logging |
||
11 | |||
12 | import jsonschema |
||
0 ignored issues
–
show
|
|||
13 | from jsonschema import ( |
||
0 ignored issues
–
show
The import
jsonschema could not be resolved.
This can be caused by one of the following: 1. Missing DependenciesThis 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 filesThis error could also result from missing ![]() |
|||
14 | SchemaError, |
||
15 | ValidationError |
||
16 | ) |
||
17 | |||
18 | _LOGGER = logging.getLogger(__name__) |
||
19 | |||
20 | |||
21 | class SchemaValidator(object): |
||
0 ignored issues
–
show
This class should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
22 | |||
23 | __slots__ = ('_input_validator') |
||
24 | |||
25 | def __init__(self, input_spec): |
||
26 | if input_spec: |
||
27 | try: |
||
28 | self._input_validator = jsonschema.Draft4Validator(input_spec) |
||
29 | |||
30 | except jsonschema.SchemaError: |
||
31 | raise |
||
32 | |||
33 | else: |
||
34 | self._input_validator = None |
||
35 | |||
36 | def validate(self, some_input): |
||
0 ignored issues
–
show
This method should have a docstring.
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods: class SomeClass:
def some_method(self):
"""Do x and return foo."""
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions. ![]() |
|||
37 | if self._input_validator is not None: |
||
38 | try: |
||
39 | self._input_validator.validate(some_input) |
||
40 | return True |
||
41 | |||
42 | except jsonschema.ValidationError: |
||
43 | raise |
||
44 | |||
45 | else: |
||
46 | # No input schema meams we accept everything |
||
47 | return True |
||
48 | |||
49 | |||
50 | __all__ = [ |
||
51 | 'SchemaError', |
||
52 | 'SchemaValidator', |
||
53 | 'ValidationError', |
||
54 | ] |
||
55 |
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.
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.