desert icon indicating copy to clipboard operation
desert copied to clipboard

Allow excluded fields to have no typehints?

Open sveinse opened this issue 5 years ago • 1 comments

Should it be possible to omit typings on fields which are excluded from the schema? Consider the following test. This code currently fails with desert.exceptions.UnknownType: Desert failed to infer the field type for None.

def test_typing_missing():
    """Test exluded field

    """

    @attr.s
    class A:
        x: int = attr.ib()
        y = attr.ib()

    schema = desert.schema_class(A, meta={'exclude': ('y')})()
    loaded = A(x=1, y=None)
    actually_dumped = {"x": 1}

    assert schema.dump(loaded) == actually_dumped

sveinse avatar Mar 27 '20 23:03 sveinse

That sounds like a good idea.

python-desert avatar Mar 28 '20 00:03 python-desert