Skip to content

Conversation

mykolasolodukha
Copy link
Contributor

@mykolasolodukha mykolasolodukha commented Sep 7, 2020

Change Summary

Added rediss to RedisDsn.allowed_schemes.

Related issue number

This PR closes #1877

Checklist

  • Unit tests for the changes exist
  • Tests pass on CI and coverage remains at 100%
  • Documentation reflects the changes where applicable
  • changes/1911-TrDex.md file added describing change
    (see changes/README.md for details)

@codecov
Copy link

codecov bot commented Sep 7, 2020

Codecov Report

Merging #1911 (2dbbe5b) into master (31bc243) will not change coverage.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##            master     #1911   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           21        21           
  Lines         4093      4133   +40     
  Branches       823       832    +9     
=========================================
+ Hits          4093      4133   +40     
Impacted Files Coverage Δ
pydantic/networks.py 100.00% <100.00%> (ø)
pydantic/json.py 100.00% <0.00%> (ø)
pydantic/types.py 100.00% <0.00%> (ø)
pydantic/fields.py 100.00% <0.00%> (ø)
pydantic/schema.py 100.00% <0.00%> (ø)
pydantic/validators.py 100.00% <0.00%> (ø)
pydantic/dataclasses.py 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 31bc243...2dbbe5b. Read the comment docs.

@mykolasolodukha mykolasolodukha marked this pull request as ready for review September 7, 2020 18:27
Copy link
Collaborator

@PrettyWood PrettyWood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo in changelog. Otherwise LGTM !

@PrettyWood
Copy link
Collaborator

PrettyWood commented Sep 9, 2020

@TrDex I reckon you should link this issue #1877 as your PR adds rediss.
You could also go a bit further by changing here ?P<user>[^\s:/]+ into ?P<user>[^\s:/]*.
This way you could add both examples 'rediss://redis' and 'redis://:123@redis' in your tests and fully solve the issue. WDYT ?

Co-authored-by: PrettyWood <em.jolibois@gmail.com>
@mykolasolodukha
Copy link
Contributor Author

@TrDex I reckon you should link this issue #1877 as your PR adds rediss.

Thanks a lot @PrettyWood ! I updated the PR comment (hope it works that way, that's one of my first PRs, lol)

You could also go a bit further by changing here ?P<user>[^\s:/]+ into ?P<user>[^\s:/]*.
This way you could add both examples 'rediss://redis' and 'redis://:123@redis' in your tests and fully solve the issue. WDYT ?

Okay, I'll update that too, and make corresponding tests as well

dependabot bot and others added 2 commits September 10, 2020 15:20
* Bump black from 19.10b0 to 20.8b1

Bumps [black](https://github.com/psf/black) from 19.10b0 to 20.8b1.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/master/CHANGES.md)
- [Commits](https://github.com/psf/black/commits)

Signed-off-by: dependabot[bot] <support@github.com>

* fix: run `make format`

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: PrettyWood <em.jolibois@gmail.com>
@@ -54,7 +54,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
Copy link
Member

@samuelcolvin samuelcolvin Oct 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is quite a significant change - allow password without user.

I think it's a good idea but it needs:

  • to be noted in documentation
  • to have it's own item in change log
  • to have tests covering this case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these items still need resolving.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TrDex this can't move forward until you act upon this comment.

@PrettyWood PrettyWood mentioned this pull request Nov 5, 2020
@nuno-andre
Copy link
Contributor

Additionally:

  • The path, if any, should only be numeric (without leading zeros) and with a single segment.
  • All fields after the scheme are optional. hostname defaults to localhost, port to 6379 and path to 0.

https://www.iana.org/assignments/uri-schemes/prov/redis

Copy link
Member

@samuelcolvin samuelcolvin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also please fix linting.

@@ -54,7 +54,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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@TrDex this can't move forward until you act upon this comment.

@mykolasolodukha
Copy link
Contributor Author

@samuelcolvin I worked on your comments about allowing password without user.

  • It's noted in the documentation.
  • It has its own item in the changelog.
  • It has tests covering this case.

@samuelcolvin samuelcolvin merged commit aacf592 into pydantic:master Dec 30, 2020
tomasz-kaminski-jir pushed a commit to tomasz-kaminski-jir/pyd_analyze that referenced this pull request Mar 23, 2025
* Add `rediss` (Redis over SSL) protocol to `RedisDsn`

* Update docs

* Update changes history

* Fix typo in `changes/1911-TrDex.md`

Co-authored-by: PrettyWood <em.jolibois@gmail.com>

* Bump black from 19.10b0 to 20.8b1 (#1909)

* Bump black from 19.10b0 to 20.8b1

Bumps [black](https://github.com/psf/black) from 19.10b0 to 20.8b1.
- [Release notes](https://github.com/psf/black/releases)
- [Changelog](https://github.com/psf/black/blob/master/CHANGES.md)
- [Commits](https://github.com/psf/black/commits)

Signed-off-by: dependabot[bot] <support@github.com>

* fix: run `make format`

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: PrettyWood <em.jolibois@gmail.com>

* Allow URLs without `user` part

Refer to #1877

* Update docs

* Allow Redis DSN with schema only

Refer to pydantic/pydantic#1911 (comment)
Refer to https://www.iana.org/assignments/uri-schemes/prov/redis

* Fix lint error

* Fix lint error

* Set `parts: Dict[str, Optional[str]]` instead of `Dict[str, str]`

* Fix linting

* More verbose default values set in `RedisDsn.validate_parts()`

* Fix linting 2

* Fix typo in docs

* Add a note in the changelog

* Add test case for URL without `user` part

* change port in test

Co-authored-by: PrettyWood <em.jolibois@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Samuel Colvin <s@muelcolvin.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RedisDsn canot enable redis url with password and ssl schema
5 participants