|
7 | 7 | Draft4Validator,
|
8 | 8 | Draft6Validator,
|
9 | 9 | Draft7Validator,
|
10 |
| - FormatChecker, |
| 10 | + FormatChecker |
11 | 11 | )
|
12 | 12 | from scrapy_jsonschema.draft import (
|
13 | 13 | JSON_SCHEMA_DRAFT_3,
|
@@ -63,42 +63,42 @@ def __new__(mcs, class_name, bases, attrs):
|
63 | 63 | cls = super(JsonSchemaMeta, mcs).__new__(mcs, class_name, bases, attrs)
|
64 | 64 |
|
65 | 65 | fields = {}
|
66 |
| - schema = attrs.get("jsonschema", {}) |
| 66 | + schema = attrs.get('jsonschema', {}) |
67 | 67 | if cls.merge_schema:
|
68 | 68 | # priority: left to right
|
69 | 69 | for base in bases:
|
70 |
| - base_schema = getattr(base, "jsonschema", None) |
| 70 | + base_schema = getattr(base, 'jsonschema', None) |
71 | 71 | if base_schema:
|
72 | 72 | schema = _merge_schema(schema, base_schema)
|
73 |
| - setattr(cls, "jsonschema", schema) |
| 73 | + setattr(cls, 'jsonschema', schema) |
74 | 74 | if not schema:
|
75 | 75 | raise ValueError(
|
76 | 76 | '{} must contain "jsonschema" attribute'.format(cls.__name__)
|
77 | 77 | )
|
78 | 78 | cls.validator = cls._get_validator(schema)
|
79 | 79 | cls.validator.check_schema(schema)
|
80 |
| - for k in schema["properties"]: |
| 80 | + for k in schema['properties']: |
81 | 81 | fields[k] = Field()
|
82 | 82 | cls.fields = cls.fields.copy()
|
83 | 83 | cls.fields.update(fields)
|
84 | 84 |
|
85 |
| - pattern_properties = schema.get("patternProperties", {}) |
| 85 | + pattern_properties = schema.get('patternProperties', {}) |
86 | 86 | cls.pattern_properties = [
|
87 | 87 | re.compile(p)
|
88 | 88 | for p in pattern_properties.keys()
|
89 |
| - if p is not "additionalProperties" |
| 89 | + if p is not 'additionalProperties' |
90 | 90 | ]
|
91 | 91 | return cls
|
92 | 92 |
|
93 | 93 | @classmethod
|
94 | 94 | def _get_validator(cls, schema):
|
95 |
| - draft_version = schema.get("$schema") |
| 95 | + draft_version = schema.get('$schema') |
96 | 96 | # Default to Draft4Validator for backward-compatibility
|
97 | 97 | validator_class = cls.draft_to_validator.get(
|
98 | 98 | draft_version, Draft4Validator
|
99 | 99 | )
|
100 | 100 | format_checker = cls.draft_to_format_checker.get(
|
101 |
| - schema.get("$schema"), draft4_format_checker |
| 101 | + schema.get('$schema'), draft4_format_checker |
102 | 102 | )
|
103 | 103 | return validator_class(schema, format_checker=format_checker)
|
104 | 104 |
|
|
0 commit comments