Mentions légales du service

Skip to content

review and simplify typed_singledispatch

Bruno Guillon requested to merge design/typed_singledispatch into master

We need a functools.singledispatch like decorator, that dispatch according to the first argument value (which is expected to be a type) rather than from its type (as done by functools.singledispatch). An implementation, relying on functools.singledispatch implementation is proposed (in querybuilder/utils/decorators.py). It is fully typed-check (modulo, one "ignore"), and tested (in querybuilder/tests/test_decorators.py). It might be used to replace the former deprecated Supercast instrumental class, because it proposed, in any decorated function, the special keyworded parameter dispatch_assuming_type which allow to ensure that a given type is assumed by the dispatcher.

Merge request reports