Repository: redis/redis-py
File: redis/connection.py (Python)

Code before:
        if url.port:
            kwargs["port"] = int(url.port)

        # If there's a path argument, use it as the db argument if a
        # querystring value wasn't specified
        if url.path and "db" not in kwargs:
            try:
                kwargs["db"] = int(unquote(url.path).replace("/", ""))
            except (AttributeError, ValueError):
                pass

        if url.scheme == "rediss":
            kwargs["connection_class"] = SSLConnection

            if "ssl_verify_flags_config" in kwargs:
                # flags are passed in as a string representation of a list,
                # e.g. [(VERIFY_X509_STRICT, False), (VERIFY_X509_PARTIAL_CHAIN, True)]
                # To parse it sucessfully, we need transform the flags to strings with quotes.
                verify_flags_config_str = kwargs.pop("ssl_verify_flags_config")
                # First wrap any VERIFY_* name in quotes
                verify_flags_config_str = re.sub(
                    r"\b(VERIFY_[A-Z0-9_]+)\b", r'"\1"', verify_flags_config_str
                )

                # transform the string to a list of tuples - the first element of each tuple is a string containing the name of the flag,
                # and the second is a boolean that indicates if the flad should be enabled or disabled
                verify_flags_config = ast.literal_eval(verify_flags_config_str)

                ssl_verify_flags_config_parsed = []
                for flag, enabled in verify_flags_config:
                    if not hasattr(VerifyFlags, flag):
                        raise ValueError(f"Invalid ssl verify flag: {flag}")
                    if not isinstance(enabled, bool):
                        raise ValueError(
                            f"Invalid ssl verify flag enabled/disabled value: {enabled}"
                        )
                    ssl_verify_flags_config_parsed.append(
                        (getattr(VerifyFlags, flag), enabled)
                    )

                kwargs["ssl_verify_flags_config"] = ssl_verify_flags_config_parsed

    return kwargs


_CP = TypeVar("_CP", bound="ConnectionPool")


class ConnectionPool:
    """
    Create a connection pool. ``If max_connections`` is set, then this

Review comment (suggestion):
Typo in comment: 'flad' should be 'flag'
```suggestion
                # and the second is a boolean that indicates if the flag should be enabled or disabled
```

Code after:
    if url.scheme == "unix":
        if url.path:
            kwargs["path"] = unquote(url.path)
        kwargs["connection_class"] = UnixDomainSocketConnection

    else:  # implied:  url.scheme in ("redis", "rediss"):
        if url.hostname:
            kwargs["host"] = unquote(url.hostname)
        if url.port:
            kwargs["port"] = int(url.port)

        # If there's a path argument, use it as the db argument if a
        # querystring value wasn't specified
        if url.path and "db" not in kwargs:
            try:
                kwargs["db"] = int(unquote(url.path).replace("/", ""))
            except (AttributeError, ValueError):
                pass

        if url.scheme == "rediss":
            kwargs["connection_class"] = SSLConnection

    return kwargs


_CP = TypeVar("_CP", bound="ConnectionPool")


class ConnectionPool:
    """
    Create a connection pool. ``If max_connections`` is set, then this
    object raises :py:class:`~redis.exceptions.ConnectionError` when the pool's
    limit is reached.

    By default, TCP connections are created unless ``connection_class``
    is specified. Use class:`.UnixDomainSocketConnection` for
    unix sockets.
    :py:class:`~redis.SSLConnection` can be used for SSL enabled connections.

    Any additional keyword arguments are passed to the constructor of
    ``connection_class``.
    """

    @classmethod
    def from_url(cls: Type[_CP], url: str, **kwargs) -> _CP:
        """
        Return a connection pool configured from the given URL.

        For example::

            redis://[[username]:[password]]@localhost:6379/0