diff --git a/changes/1275-samuelcolvin.md b/changes/1275-samuelcolvin.md new file mode 100644 index 0000000000..5d16bc86ea --- /dev/null +++ b/changes/1275-samuelcolvin.md @@ -0,0 +1 @@ +Remove `user_required = True` from `RedisDsn`, neither user nor password are required. diff --git a/docs/usage/types.md b/docs/usage/types.md index 97853dd07a..a9b2a451b1 100644 --- a/docs/usage/types.md +++ b/docs/usage/types.md @@ -508,8 +508,9 @@ For URI/URL validation the following types are available: - `AnyUrl`: any scheme allowed, TLD not required - `AnyHttpUrl`: schema `http` or `https`, TLD not required - `HttpUrl`: schema `http` or `https`, TLD required, max length 2083 -- `PostgresDsn`: schema `postgres` or `postgresql`, userinfo required, TLD not required -- `RedisDsn`: schema `redis`, userinfo required, tld not required +- `PostgresDsn`: schema `postgres` or `postgresql`, user info required, TLD not required +- `RedisDsn`: schema `redis`, user info not required, tld not required (CHANGED: user info not required from + **v1.6** onwards) - `stricturl`, method with the following keyword arguments: - `strip_whitespace: bool = True` - `min_length: int = 1` diff --git a/pydantic/networks.py b/pydantic/networks.py index 960520acfd..9dca1af8ff 100644 --- a/pydantic/networks.py +++ b/pydantic/networks.py @@ -274,7 +274,6 @@ class PostgresDsn(AnyUrl): class RedisDsn(AnyUrl): allowed_schemes = {'redis'} - user_required = True def stricturl( diff --git a/tests/test_networks.py b/tests/test_networks.py index b28392bc35..62f4ec3fcf 100644 --- a/tests/test_networks.py +++ b/tests/test_networks.py @@ -324,10 +324,11 @@ class Model(BaseModel): Model(a='http://example.org') assert exc_info.value.errors()[0]['type'] == 'value_error.url.scheme' - with pytest.raises(ValidationError) as exc_info: - Model(a='redis://localhost:5432/app') - error = exc_info.value.errors()[0] - assert error == {'loc': ('a',), 'msg': 'userinfo required in URL but missing', 'type': 'value_error.url.userinfo'} + # password is not required for redis + m = Model(a='redis://localhost:5432/app') + assert m.a == 'redis://localhost:5432/app' + assert m.a.user is None + assert m.a.password is None def test_custom_schemes():