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

Code before:
        if event_dispatcher is None:
            self._event_dispatcher = EventDispatcher()
        else:
            self._event_dispatcher = event_dispatcher
        # auto_close_connection_pool only has an effect if connection_pool is
        # None. It is assumed that if connection_pool is not None, the user
        # wants to manage the connection pool themselves.
        if auto_close_connection_pool is not None:
            warnings.warn(
                DeprecationWarning(
                    '"auto_close_connection_pool" is deprecated '
                    "since version 5.0.1. "
                    "Please create a ConnectionPool explicitly and "
                    "provide to the Redis() constructor instead."
                )
            )
        else:
            auto_close_connection_pool = True

        if not connection_pool:
            # Create internal connection pool, expected to be closed by Redis instance
            if not retry_on_error:
                retry_on_error = []

            # Handle driver_info: if provided, use it; otherwise create from lib_name/lib_version
            if driver_info is not None:
                computed_driver_info = driver_info
            else:
                # Fallback: create DriverInfo from lib_name and lib_version
                # Use defaults if not provided
                name = lib_name if lib_name is not None else "redis-py"
                version = lib_version if lib_version is not None else get_lib_version()
                computed_driver_info = DriverInfo(name=name, lib_version=version)

            kwargs = {
                "db": db,
                "username": username,
                "password": password,
                "credential_provider": credential_provider,
                "socket_timeout": socket_timeout,
                "encoding": encoding,
                "encoding_errors": encoding_errors,
                "decode_responses": decode_responses,
                "retry_on_error": retry_on_error,
                "retry": copy.deepcopy(retry),
                "max_connections": max_connections,
                "health_check_interval": health_check_interval,
                "client_name": client_name,
                "driver_info": computed_driver_info,
                "redis_connect_func": redis_connect_func,
                "protocol": protocol,

Review comment (performance):
The same fallback logic is repeated in 4 places: 
client.py ,  asyncio/client.py, connection.py, asyncio/connection.py 

```
  if driver_info is not None:
      computed_driver_info = driver_info
  else:
      name = lib_name if lib_name is not None else "redis-py"
      version = lib_version if lib_version is not None else get_lib_version()
      computed_driver_info = DriverInfo(name=name, lib_version=version)
```
You could add a helper in `driver_info.py`  - then each call site becomes a one-liner.

Code after:
            self._event_dispatcher = EventDispatcher()
        else:
            self._event_dispatcher = event_dispatcher
        # auto_close_connection_pool only has an effect if connection_pool is
        # None. It is assumed that if connection_pool is not None, the user
        # wants to manage the connection pool themselves.
        if auto_close_connection_pool is not None:
            warnings.warn(
                DeprecationWarning(
                    '"auto_close_connection_pool" is deprecated '
                    "since version 5.0.1. "
                    "Please create a ConnectionPool explicitly and "
                    "provide to the Redis() constructor instead."
                )
            )
        else:
            auto_close_connection_pool = True

        if not connection_pool:
            # Create internal connection pool, expected to be closed by Redis instance
            if not retry_on_error:
                retry_on_error = []

            # Handle driver_info: if provided, use it; otherwise create from lib_name/lib_version
            computed_driver_info = resolve_driver_info(
                driver_info, lib_name, lib_version
            )

            kwargs = {
                "db": db,
                "username": username,
                "password": password,
                "credential_provider": credential_provider,
                "socket_timeout": socket_timeout,
                "encoding": encoding,
                "encoding_errors": encoding_errors,
                "decode_responses": decode_responses,
                "retry_on_error": retry_on_error,
                "retry": copy.deepcopy(retry),
                "max_connections": max_connections,
                "health_check_interval": health_check_interval,
                "client_name": client_name,
                "driver_info": computed_driver_info,
                "redis_connect_func": redis_connect_func,
                "protocol": protocol,
            }
            # based on input, setup appropriate connection args
            if unix_socket_path is not None:
                kwargs.update(
                    {
                        "path": unix_socket_path,