-
-
Notifications
You must be signed in to change notification settings - Fork 903
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
Bugfix of regex at FloatConvertor #1942
Conversation
1. ValueError: could not convert string to float if path parameters '/path/{number:float}' like /path/1-1, /path/2+2, /path/3^3 2. Bug: A dot in regex of class FloatConvetor is also a metacharacter, it is used to match any character. 3. Fix: I need to escape it, so regex = "[0-9]+(\.[0-9]+)?"
Would you mind adding a test for it? |
Below is the simple test.py, I curl http://localhost:8000/path/1.1 is passed, but http://localhost:8000/path/2-2 raises 500 Server Error: ValueError: could not convert string to float: '2-2'
|
Sorry my bad, I deleted my fork to affect to close this pull request. It is related to the bugfix of #1944. |
#1944 has the same goal, can we close this and continue there? |
* Bugfix of regex at FloatConvertor (version 2) For passing your checks of #1942 A correct statement is: regex = r"[0-9]+(\.[0-9]+)?" Reference: https://www.flake8rules.com/rules/W605.html I have no problem to corrected without 'r' prefix directly at /site-packages/starlette/convertors.py of my computer. Having submitted last pull-request, I realized to add a 'r' prefix to pass your tests. * Add test Co-authored-by: Ching <thus.kindly@gmail.com>
* Bugfix of regex at FloatConvertor (version 2) For passing your checks of #1942 A correct statement is: regex = r"[0-9]+(\.[0-9]+)?" Reference: https://www.flake8rules.com/rules/W605.html I have no problem to corrected without 'r' prefix directly at /site-packages/starlette/convertors.py of my computer. Having submitted last pull-request, I realized to add a 'r' prefix to pass your tests. * Add test Co-authored-by: Ching <thus.kindly@gmail.com>
* Bugfix of regex at FloatConvertor (version 2) For passing your checks of encode/starlette#1942 A correct statement is: regex = r"[0-9]+(\.[0-9]+)?" Reference: https://www.flake8rules.com/rules/W605.html I have no problem to corrected without 'r' prefix directly at /site-packages/starlette/convertors.py of my computer. Having submitted last pull-request, I realized to add a 'r' prefix to pass your tests. * Add test Co-authored-by: Ching <thus.kindly@gmail.com>
* Bugfix of regex at FloatConvertor (version 2) For passing your checks of encode/starlette#1942 A correct statement is: regex = r"[0-9]+(\.[0-9]+)?" Reference: https://www.flake8rules.com/rules/W605.html I have no problem to corrected without 'r' prefix directly at /site-packages/starlette/convertors.py of my computer. Having submitted last pull-request, I realized to add a 'r' prefix to pass your tests. * Add test Co-authored-by: Ching <thus.kindly@gmail.com>
ValueError: could not convert string to float if path parameters '/path/{number:float}' like /path/1-1, /path/2+2, /path/3^3
Bug: A dot in regex of class FloatConvetor is also a metacharacter, it is used to match any character.
Fix: I need to add a backslash escape the dot, so regex = "[0-9]+(\.[0-9]+)?"
The starting point for contributions should usually be a discussion
Simple documentation typos may be raised as stand-alone pull requests, but otherwise please ensure you've discussed your proposal prior to issuing a pull request.
This will help us direct work appropriately, and ensure that any suggested changes have been okayed by the maintainers.