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
Made user info not required for RedisDSN. This will fix the issue #1275 #1302
Changes from all commits
2719976
6b48dbe
184e8b6
4ccb782
0e68f2c
8347d2b
1ab9540
46f6be2
6bc24b9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Made user info optional for `RedisDSN` | ||
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -53,7 +53,7 @@ def url_regex() -> Pattern[str]: | |||||||
if _url_regex_cache is None: | ||||||||
_url_regex_cache = re.compile( | ||||||||
r'(?:(?P<scheme>[a-z][a-z0-9+\-.]+)://)?' # scheme https://tools.ietf.org/html/rfc3986#appendix-A | ||||||||
r'(?:(?P<user>[^\s:/]+)(?::(?P<password>[^\s/]*))?@)?' # user info | ||||||||
r'(?:(?P<user>[^\s:/]+)?(?::(?P<password>[^\s/]*))?@)?' # user info | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
as i understand it user and password are now independent, so should go on separate lines. |
||||||||
r'(?:' | ||||||||
r'(?P<ipv4>(?:\d{1,3}\.){3}\d{1,3})|' # ipv4 | ||||||||
r'(?P<ipv6>\[[A-F0-9]*:[A-F0-9:]+\])|' # ipv6 | ||||||||
|
@@ -146,8 +146,9 @@ def build( | |||||||
url = scheme + '://' | ||||||||
if user: | ||||||||
url += user | ||||||||
if password: | ||||||||
url += ':' + password | ||||||||
if password: | ||||||||
url += ':' + password | ||||||||
if user or password: | ||||||||
url += '@' | ||||||||
url += host | ||||||||
if port: | ||||||||
|
@@ -189,7 +190,8 @@ def validate(cls, value: Any, field: 'ModelField', config: 'BaseConfig') -> 'Any | |||||||
raise errors.UrlSchemePermittedError(cls.allowed_schemes) | ||||||||
|
||||||||
user = parts['user'] | ||||||||
if cls.user_required and user is None: | ||||||||
password = parts['password'] | ||||||||
if cls.user_required and user is None and password is None: | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Humm, this is a breaking change (and arguably a bug) since now user is no longer required when To fix this, either we need to:
I think I favour option 1., but on |
||||||||
raise errors.UrlUserInfoError() | ||||||||
|
||||||||
host, tld, host_type, rebuild = cls.validate_host(parts) | ||||||||
|
@@ -201,7 +203,7 @@ def validate(cls, value: Any, field: 'ModelField', config: 'BaseConfig') -> 'Any | |||||||
None if rebuild else url, | ||||||||
scheme=scheme, | ||||||||
user=user, | ||||||||
password=parts['password'], | ||||||||
password=password, | ||||||||
host=host, | ||||||||
tld=tld, | ||||||||
host_type=host_type, | ||||||||
|
@@ -274,7 +276,7 @@ class PostgresDsn(AnyUrl): | |||||||
|
||||||||
class RedisDsn(AnyUrl): | ||||||||
allowed_schemes = {'redis'} | ||||||||
user_required = True | ||||||||
user_required = False | ||||||||
|
||||||||
|
||||||||
def stricturl( | ||||||||
|
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.
If we're adding
password_required
andcredentials_required
we should put that in the change description.