Skip to content

unhashable definitions in schema #572

@AntoineD

Description

@AntoineD

Hi,

I've created a schema with a definitions section, but jsonschema 3.0.1 cannot deal with it. Here is a reproducer :

schema.json contains (from here):

{
    "type": "array",
    "items": { "$ref": "#/definitions/positiveInteger" },
    "definitions": {
        "positiveInteger": {
            "type": "integer",
            "exclusiveMinimum": 0
        }
    }
}

Test code:

import jsonschema
import json
schema = json.load(open('schema.json'))
jsonschema.Draft7Validator({}, schema)

I get this exception:

  File "/xxx/lib/python3.6/site-packages/jsonschema/validators.py", line 276, in __init__
    _generate_legacy_type_checks(types),
  File "/xxx/lib/python3.6/site-packages/jsonschema/validators.py", line 83, in _generate_legacy_type_checks
    definitions[typename] = gen_type_check(pytypes)
  File "/xxx/lib/python3.6/site-packages/jsonschema/validators.py", line 71, in gen_type_check
    pytypes = _utils.flatten(pytypes)
  File "/xxx/lib/python3.6/site-packages/jsonschema/_utils.py", line 161, in flatten
    types.add(thing)
TypeError: unhashable type: 'dict'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions