Skip to content

Commit

Permalink
Allow dispatch of the etuple function
Browse files Browse the repository at this point in the history
The `etuple` function returns an instance of the `ExpressionTuple`
class. If we wish to return an instance of a subclass of
`ExpressionTuple` we need to implement a new function. This allows one
to dispatch the `etuple` function to keep a uniform API.
  • Loading branch information
rlouf authored and brandonwillard committed Sep 6, 2022
1 parent e4e6fe0 commit e3045d2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions etuples/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
from collections.abc import Generator, Sequence
from typing import Callable

from multipledispatch import dispatch

etuple_repr = reprlib.Repr()
etuple_repr.maxstring = 100
etuple_repr.maxother = 100
Expand Down Expand Up @@ -337,6 +339,7 @@ def __hash__(self):
return hash(self._tuple)


@dispatch([object])
def etuple(*args, **kwargs):
"""Create an ExpressionTuple from the argument list.
Expand Down

0 comments on commit e3045d2

Please sign in to comment.