Skip to content

_WrappedReferencingError is unhashable #1126

@johnnymetz

Description

@johnnymetz

Background

jsonschema.exceptions._WrappedReferencingError is unhashable. This is causing issues with error tracking services (e.g. Rollbar) when trying to report these errors to the service.

Steps to Reproduce

import jsonschema
from typing import Hashable

try:
    jsonschema.validate(
        instance={
            "definitions": {"apiVersion": "v1"},
        },
        schema={
            "properties": {
                "definitions": {
                    "$ref": "https://app.pixiebrix.com/schemas/innerDefinition#",
                },
            },
        },
    )
except jsonschema.exceptions._WrappedReferencingError as e:
    print(isinstance(e, Hashable))  # prints False
    print(hash(e))  # raisesTypeError: unhashable type: '_WrappedReferencingError'

Expected Behavior

I believe exceptions should be hashable. See the following simple example:

from typing import Hashable

try:
    assert False
except Exception as e:
    print(isinstance(e, Hashable))  # prints True
    print(hash(e))  # prints 270994222

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugSomething doesn't work the way it should.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions