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.
Description
CheckedPMap.create(..., ignore_extra=True)does not forwardignore_extrato the nested key/valueCheckedType.createcalls, so extra fields in a nested checked value still raise even thoughignore_extra=Truewas requested.CheckedPVector/CheckedPSetthreadignore_extracorrectly;CheckedPMapis the one collection that drops it.Reproduction
Expected vs actual
ignore_extra=Trueis honored (extra field dropped), as it is forCheckedPVector/CheckedPSetAttributeErroris raisedRoot cause
CheckedPMap.createcallschecked_key_type.create(key)/checked_value_type.create(value)without passingignore_extra=ignore_extra. The sibling helper_checked_type_create(used by the vector/set) threads it through;CheckedPMap.createshould do the same.