Avoid invalid escape sequences, use raw strings
What does this PR do?
Fixes invalid escape sequences in strings, they are illegal in python, and will throw a SyntaxError if run with "-W error", and always throw a syntax error starting with python-3.12 (planned). With python between 3.6 and 3.11 and "-W default" they produce a DeprecationWarning:
> python -W error -c '"(.*?)-\d{5}-of-\d{5}"'  ✔  File "<string>", line 1
"(.*?)-\d{5}-of-\d{5}"
^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid escape sequence '\d'
This has been fixed in the past, e.g. https://github.com/huggingface/transformers/pull/4924 - but missing linter support and the fact that python only fails this with "-W" flag set has let the issue be re-introduced. This PR fixes those occurrences and enables ruff "W605" error, which will prevent this for the future.
Who can review?
Maybe @sgugger who added ruff in the first place or (Why was "W605" disabled when switching to ruff?) @patrickvonplaten wo recently introduced some invalid escape sequences @LysandreJik who merged the linked fix from 2020
The documentation is not available anymore as the PR was closed or merged.
Failures are unrelated to this PR and due to the last release of huggingface_hub. All is fixed on main so merging :-)
Rebased on top of current main branch to pass the tests.
Rebased on top of current main branch to pass the tests.
Does not seem to help the tests, let me know if I should do anything else for this PR
The Hub is currently having high-response times due to some abusive traffic, which is why the tests are all red. I just forgot to push the merge button yesterday, so merging this as it shouldn't have any negative impact on main.