♻ Simplify internal RegEx in fastapi/utils.py#5057
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5057 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 532 532
Lines 13672 13672
=========================================
Hits 13672 13672
Continue to review full report at Codecov.
|
|
📝 Docs preview for commit 9786b7f at: https://62afeb41aa8c7445d0b7c931--fastapi.netlify.app |
JarroVGIT
left a comment
There was a problem hiding this comment.
Agree, \W is the equivalent of [^a-zA-Z0-9_] and is more elegant.
No, that's not true. It's equivalent to >>> import re
>>> re.match(r'\W', 'ü')
>>> re.match(r'\w', 'ü')
<re.Match object; span=(0, 1), match='ü'>This change may lead to better support for languages with non-ASCII characters, but it's not precisely equivalent to the old code. |
I stand corrected. I took my information from regex101.com, and you are completely right. If this changes the behaviour, then I would expect a test case that would illustrate the exact intended behaviour. |
|
Great, thanks @pylounge! 🍰 |
Replace regex for simple