unasync icon indicating copy to clipboard operation
unasync copied to clipboard

Allow pattern matching / substitutions

Open johtso opened this issue 5 years ago • 2 comments

Think this would be a generally very useful feature. Easy to structure your code so that various things have Async/Sync prefixes, and then you can just target them all with a regex instead of having to list every token.

This is something that httpcore are doing in their custom unasync script https://github.com/encode/httpcore/blob/0.11.1/unasync.py#L10

johtso avatar Oct 05 '20 08:10 johtso

Would additional_replacements be enough for your needs? https://unasync.readthedocs.io/en/latest/#usage

pquentin avatar Oct 05 '20 09:10 pquentin

Well, that's still just string for string replacement, no regexes right?

I did just realise that with the case of Async/Sync prefixed class names, we just hard-code the replacement. https://github.com/python-trio/unasync/blob/master/src/unasync/init.py#L106-L108

A guess a small benefit of having it implemented as a regex is that it will then be with all the other default replacements at the top of the file rather than hidden in the code.

johtso avatar Oct 05 '20 10:10 johtso