Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow pattern matching / substitutions #68

Open
johtso opened this issue Oct 5, 2020 · 2 comments
Open

Allow pattern matching / substitutions #68

johtso opened this issue Oct 5, 2020 · 2 comments

Comments

@johtso
Copy link

johtso commented Oct 5, 2020

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

@pquentin
Copy link
Member

pquentin commented Oct 5, 2020

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

@johtso
Copy link
Author

johtso commented Oct 5, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants