enthought / enthought/traits

Adaption feature request: `adapt` to any protocol of a set of protocols; pick the most specific

Open
#244 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
462
Forks
90
PR merge metrics
No merged PRs in 30d

Description

Some functions need to decide on how to proceed depending on the type of an argument. If adaption is used, then this would usually imply that if the type is not known, then adaption should be attempted. A problem arises if the argument is adaptable to multiple of the expected types. If the function has a clear favourite type, then it can just call `adapt` with that type and if that fails, continue with the next type. But if the function does not have a clear favourite, then we'd want to get the adapter that is most specific to the incoming argument i.e. the shortest adaption chain. Currently, there is neither an API that allows one to determine the adaption chain length (it's hidden in `AdaptionManager._adapt`), nor does that function allow to ask for an adapter to a set of protocols.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.