typeshed icon indicating copy to clipboard operation
typeshed copied to clipboard

Add missing ssl related arguments to Redis from_url method

Open jonathan-h-grebe opened this issue 1 year ago • 5 comments

solves #12149, the gist of which is:

  • a Redis client (redis.Redis) can be obtained by using either its constructor, or from_url method
  • connection options can be specified as arguments to either
  • some of those options (eg ssl_ca_data) were missing as defined parameters for from_url
  • this caused mypy to give false positives those missing SSL options were specified as kwargs to from_url

Change Details

To fix the issue, following 9 options were added as params to from_url

  • ssl_ca_path
  • ssl_ca_data
  • ssl_password
  • ssl_validate_ocsp
  • ssl_validate_ocsp_stapled
  • ssl_ocsp_context
  • ssl_ocsp_expected_cert
  • redis_connect_func
  • credential_provider

jonathan-h-grebe avatar Jun 19 '24 13:06 jonathan-h-grebe

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Jun 19 '24 13:06 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Jun 19 '24 13:06 github-actions[bot]

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

github-actions[bot] avatar Jun 19 '24 13:06 github-actions[bot]

Thanks! This becomes a bit repetitive, maybe we should use Unpack[] with a TypedDict (PEP-692) to define these kwargs?

JelleZijlstra avatar Jun 20 '24 07:06 JelleZijlstra

Thanks! This becomes a bit repetitive, maybe we should use Unpack[] with a TypedDict (PEP-692) to define these kwargs?

Good point - those (almost) identical parameters being repeated 5 times do seem a bit much.

However, as TypedDicts don't support default values for keys, it wouldn't be possible to define the parameter defaults. We could get around that by defining a dataclass, but I think that would quite an impact on existing code bases, having to switch from dict to class based syntax.

jonathan-h-grebe avatar Jun 28 '24 13:06 jonathan-h-grebe