Skip to content

Two tuples as dictionary keys report a false alarm of SchemaMissingKeyError #312

Description

@tjyuyao

I am using schema 0.7.5 and python 3.11.

Following is a minimal code to reproduce

from schema import *

data_schema = Schema({
    ('map_point', 'to', 'map_polygon'): {},
    ('map_polygon', 'to', 'map_polygon'): {},
}, ignore_extra_keys=True).validate(
    {
        ('map_point', 'to', 'map_polygon'): {},
        ('map_polygon', 'to', 'map_polygon'): {},
    }
)

It will give the error:

Traceback (most recent call last):
  File "/home/hyuyao/2024/trackpred/qcnet_plug_in/qcnet_official_study/data_schema.py", line 7, in <module>
    }, ignore_extra_keys=True).validate(
                               ^^^^^^^^^
  File "/home/hyuyao/miniconda3/envs/RAMoPred/lib/python3.11/site-packages/schema.py", line 420, in validate
    raise SchemaMissingKeyError(message, e.format(data) if e else None)
schema.SchemaMissingKeyError: Missing key: ('map_polygon', 'to', 'map_polygon')

The expected behavior is to pass the validation without raise the error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions