Skip to content

CheckedPMap.create does not forward ignore_extra to nested CheckedType keys/values #326

Description

@pramodavansaber

Description

CheckedPMap.create(..., ignore_extra=True) does not forward ignore_extra to the nested key/value CheckedType.create calls, so extra fields in a nested checked value still raise even though ignore_extra=True was requested. CheckedPVector / CheckedPSet thread ignore_extra correctly; CheckedPMap is the one collection that drops it.

Reproduction

from pyrsistent import CheckedPMap, PRecord, field

class Rec(PRecord):
    a = field()

class M(CheckedPMap):
    __key_type__ = str
    __value_type__ = Rec

M.create({"k": {"a": 1, "extra": 2}}, ignore_extra=True)
# AttributeError: 'extra' is not among the specified fields for Rec

Expected vs actual

  • expected: ignore_extra=True is honored (extra field dropped), as it is for CheckedPVector/CheckedPSet
  • actual: AttributeError is raised

Root cause

CheckedPMap.create calls checked_key_type.create(key) / checked_value_type.create(value) without passing ignore_extra=ignore_extra. The sibling helper _checked_type_create (used by the vector/set) threads it through; CheckedPMap.create should do the same.

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