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

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

    elif parsed.scheme in ("redis", "rediss"):
        if parsed.hostname:
            kwargs["host"] = unquote(parsed.hostname)
        if parsed.port:
            kwargs["port"] = int(parsed.port)

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

        if parsed.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)

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

                kwargs["ssl_verify_flags_config"] = verify_flags_config_config_parsed
    else:
        valid_schemes = "redis://, rediss://, unix://"

Review comment (suggestion):
Typo in comment: 'sucessfully' should be 'successfully'
```suggestion
                # To parse it successfully, we need to transform the flags to strings with quotes.
```

Code after:

def parse_url(url: str) -> ConnectKwargs:
    parsed: ParseResult = urlparse(url)
    kwargs: ConnectKwargs = {}

    for name, value_list in parse_qs(parsed.query).items():
        if value_list and len(value_list) > 0:
            value = unquote(value_list[0])
            parser = URL_QUERY_ARGUMENT_PARSERS.get(name)
            if parser:
                try:
                    kwargs[name] = parser(value)
                except (TypeError, ValueError):
                    raise ValueError(f"Invalid value for '{name}' in connection URL.")
            else:
                kwargs[name] = value

    if parsed.username:
        kwargs["username"] = unquote(parsed.username)
    if parsed.password:
        kwargs["password"] = unquote(parsed.password)

    # We only support redis://, rediss:// and unix:// schemes.
    if parsed.scheme == "unix":
        if parsed.path:
            kwargs["path"] = unquote(parsed.path)
        kwargs["connection_class"] = UnixDomainSocketConnection

    elif parsed.scheme in ("redis", "rediss"):
        if parsed.hostname:
            kwargs["host"] = unquote(parsed.hostname)
        if parsed.port:
            kwargs["port"] = int(parsed.port)

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

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

    else:
        valid_schemes = "redis://, rediss://, unix://"
        raise ValueError(
            f"Redis URL must specify one of the following schemes ({valid_schemes})"
        )