-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
♻ 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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