fix: unescape escaped regex elements#145
Conversation
|
|
||
|
|
||
| def _unescape_literal_regex_elements(text: str) -> str: | ||
| return REGEX_ESCAPE_SEQUENCE.sub(r"\1", text) |
There was a problem hiding this comment.
This is basically the solution from https://mentaljetsam.wordpress.com/2007/04/13/unescape-a-python-escaped-string/ for unescaping
hofbi
left a comment
There was a problem hiding this comment.
So far I always used this as a chance to cleanup. Without the escape it is much more readable.
|
That's fair. Such slightly overly general regexes never hurt us. Nobody will accidentally create Still, this behavior is implicit and users wonder why this hook supports less than pre-commit/prek does. In the words of copilot:
Should we make this more obvious, for example by documenting? |
|
We'll continue with this in #146 |
Otherwise, the hook raises paths like
foo/bar\.txtas nonexistent, but this is accepted by pre-commit/prek.