Open mxndtaylor opened 3 weeks ago
I think I will also add custom
parameter that accepts a lambda with signature Callable[[str], list[str]]
so the end user can define their own aliasing via process instead of statically.
This would allow the user to alias their method the same way no matter what it's name was, so if the name was "bar" and we had asked for custom=lambda x: x[0] + x[-1]
(so "br" is the only alias) and then we had to change it to "baz" then without any code change, the alias updates to "bz"
added short
and sub
with follow behavior on a method named foobar
:
short=True
-> aliases f, fo, foo, foob, fooba, foobar
short=1
or sub=1
-> aliases f
short=[1, 3, 5]
or sub=[1, 3, 5]
-> aliases f, foo, fooba
The real different between short
and sub
is when applied to methods with leading underscores (_
) like _foobar
.
short
will strip them, sub
will not:
short=True
-> aliases f, fo, foo, foob, fooba, foobar
short=2
-> aliases fo
sub=2
-> aliases _f
-- notice the leading underscoreshort=[1, 3, 5]
-> aliases f, foo, fooba
sub=[1, 3, 5]
-> aliases _, _fo, _foob
-- notice the leading underscore
Describe the solution you'd like
a decorator (something like @auto_alias) that accepts string options, enum flags or boolean parameters (or some combination) that generates aliases, so make these use cases easier:
aardvark
would generatea
,aa
,aar
,aard
, etc. could accept an Sequence of ints representing indexs to terminate on, something likeshort=[1, 5]
foraardvark
would generatea
andaardv
.get_my_data_please
is given aliasgmdp
Describe alternatives you've considered
@valiases
with the exact parameters specified but this could get out of hand and turn into a lot of work to support the same use cases all at the same time. It's also static rather than dynamic. I'd need to define it per member based on it's name. The above solution would automatically change to the new aliases based on the new method name if it was ever changed