Bugfix of regex at FloatConvertor#1942
Closed
i-Ching wants to merge 1 commit intoKludex:masterfrom
i-Ching:patch-1
Closed
Bugfix of regex at FloatConvertor#1942i-Ching wants to merge 1 commit intoKludex:masterfrom i-Ching:patch-1
i-Ching wants to merge 1 commit intoKludex:masterfrom
i-Ching:patch-1
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]+)?"
Owner
|
Would you mind adding a test for it? |
Contributor
Author
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' |
Contributor
Author
|
Sorry my bad, I deleted my fork to affect to close this pull request. It is related to the bugfix of #1944. |
Contributor
|
#1944 has the same goal, can we close this and continue there? |
Kludex
added a commit
that referenced
this pull request
Dec 3, 2022
* 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 <[email protected]>
aminalaee
pushed a commit
that referenced
this pull request
Feb 13, 2023
* 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 <[email protected]>
azurelotus06
added a commit
to azurelotus06/starlette
that referenced
this pull request
Jun 27, 2024
* Bugfix of regex at FloatConvertor (version 2) For passing your checks of Kludex/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 <[email protected]>
github-actions bot
pushed a commit
to Kludex/jik
that referenced
this pull request
Aug 16, 2024
* Bugfix of regex at FloatConvertor (version 2) For passing your checks of Kludex/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 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.