Make type codecs invariant

Description

In 3.0.0-alpha4, codecs are always covariant, which leads to the following issue:

Make codecs invariant to avoid the problem. You always need to specify the exact type that your codec is handling:

The only place where we need covariance is when we only have an object to deduce the type from:

This is fine because it's handled by a separate accepts method.


For the record, we also considered keeping encoding covariant, and making decoding contravariant:

But that doesn't look like something that would be very useful in practice, so the extra complexity isn't justified.

Environment

None

Pull Requests

None
Fixed

Assignee

Alexandre Dutra

Reporter

Olivier Michallat

Labels

None

PM Priority

None

Reproduced in

None

Affects versions

None

Fix versions

Pull Request

None

Doc Impact

None

Size

None

External issue ID

None

External issue ID

None

Priority

Minor
Configure