Skip to content

Commit

Permalink
Remove six dependency (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
elacuesta authored Mar 22, 2021
1 parent d75ac89 commit 2ee3900
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 14 deletions.
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
jsonschema[format]
scrapy
six
21 changes: 9 additions & 12 deletions scrapy_jsonschema/item.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
import re
import six

from jsonschema import (
draft3_format_checker,
Draft3Validator,
draft4_format_checker,
Draft4Validator,
draft6_format_checker,
Draft6Validator,
draft7_format_checker,
Draft7Validator,
FormatChecker,
)
from scrapy.item import DictItem, Field

from scrapy_jsonschema.draft import (
JSON_SCHEMA_DRAFT_3,
JSON_SCHEMA_DRAFT_4,
JSON_SCHEMA_DRAFT_6,
JSON_SCHEMA_DRAFT_7,
)

from jsonschema import (
draft3_format_checker,
draft4_format_checker,
draft6_format_checker,
draft7_format_checker,
)

from scrapy.item import DictItem, Field

try:
# Scrapy >= 2.1
Expand All @@ -38,7 +36,7 @@ def _merge_schema(base, new):
if all(isinstance(x, dict) for x in (base, new)):
return {
key: _merge_schema(base.get(key), new.get(key))
for key in six.viewkeys(base) | six.viewkeys(new)
for key in base.keys() | new.keys()
}
if all(isinstance(x, (list, tuple)) for x in (base, new)):
return list(base) + list(new)
Expand Down Expand Up @@ -117,8 +115,7 @@ def _get_validator(cls, schema):
return validator_class(schema, format_checker=format_checker)


@six.add_metaclass(JsonSchemaMeta)
class JsonSchemaItem(DictItem):
class JsonSchemaItem(DictItem, metaclass=JsonSchemaMeta):
jsonschema = {"properties": {}}
merge_schema = False # Off for backward-compatibility

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
],
install_requires=["scrapy", "jsonschema[format]", "six"],
install_requires=["scrapy", "jsonschema[format]"],
)

0 comments on commit 2ee3900

Please sign in to comment.