Repository: apache/airflow
File: providers/microsoft/azure/src/airflow/providers/microsoft/azure/hooks/msgraph.py (Python)

Code before:
    conn_type: str = "msgraph"
    conn_name_attr: str = "conn_id"
    default_conn_name: str = "msgraph_default"
    hook_name: str = "Microsoft Graph API"

    def __init__(
        self,
        conn_id: str = default_conn_name,
        timeout: float | None = None,
        proxies: dict | None = None,
        host: str | None = None,
        scopes: str | list[str] | None = None,
        api_version: APIVersion | str | None = None,
    ):
        super().__init__()
        self.conn_id = conn_id
        self.timeout = timeout
        self.proxies = proxies
        self.host = self._ensure_protocol(host)
        if isinstance(scopes, str):
            self.scopes = [scopes]
        else:
            self.scopes = scopes or [self.DEFAULT_SCOPE]
        self.api_version = self.resolve_api_version_from_value(api_version)

    def _ensure_protocol(self, host: str, schema: str = "https") -> str:
        """Ensure URL has http:// or https:// protocol prefix."""
        if not host:
            return None

        if host.startswith(("http://", "https://")):
            return host

        self.log.warning(
            "URL '%s' is missing protocol prefix. Automatically adding '%s://'. "
            "Please update your connection configuration to include the full URL with protocol.",
            host,
            schema,
        )
        return f"{schema}://{host}"

    @classmethod
    def get_connection_form_widgets(cls) -> dict[str, Any]:
        """Return connection widgets to add to connection form."""
        from flask_appbuilder.fieldwidgets import BS3TextAreaFieldWidget, BS3TextFieldWidget
        from flask_babel import lazy_gettext
        from wtforms.fields import BooleanField, StringField

        return {
            "tenant_id": StringField(lazy_gettext("Tenant ID"), widget=BS3TextFieldWidget()),
            "drive_id": StringField(lazy_gettext("Drive ID"), widget=BS3TextFieldWidget()),

Review comment (suggestion):
```suggestion
    def _ensure_protocol(self, host: str, schema: str = "https") -> str | None:
```

Code after:
    conn_type: str = "msgraph"
    conn_name_attr: str = "conn_id"
    default_conn_name: str = "msgraph_default"
    hook_name: str = "Microsoft Graph API"

    def __init__(
        self,
        conn_id: str = default_conn_name,
        timeout: float | None = None,
        proxies: dict | None = None,
        host: str | None = None,
        scopes: str | list[str] | None = None,
        api_version: APIVersion | str | None = None,
    ):
        super().__init__()
        self.conn_id = conn_id
        self.timeout = timeout
        self.proxies = proxies
        self.host = self._ensure_protocol(host)
        if isinstance(scopes, str):
            self.scopes = [scopes]
        else:
            self.scopes = scopes or [self.DEFAULT_SCOPE]
        self.api_version = self.resolve_api_version_from_value(api_version)

    def _ensure_protocol(self, host: str | None, schema: str = "https") -> str | None:
        """Ensure URL has http:// or https:// protocol prefix."""
        if not host:
            return None

        if host.startswith(("http://", "https://")):
            return host

        self.log.warning(
            "URL '%s' is missing protocol prefix. Automatically adding '%s://'. "
            "Please update your connection configuration to include the full URL with protocol.",
            host,
            schema,
        )
        return f"{schema}://{host}"

    @classmethod
    def get_connection_form_widgets(cls) -> dict[str, Any]:
        """Return connection widgets to add to connection form."""
        from flask_appbuilder.fieldwidgets import BS3TextAreaFieldWidget, BS3TextFieldWidget
        from flask_babel import lazy_gettext
        from wtforms.fields import BooleanField, StringField

        return {
            "tenant_id": StringField(lazy_gettext("Tenant ID"), widget=BS3TextFieldWidget()),
            "drive_id": StringField(lazy_gettext("Drive ID"), widget=BS3TextFieldWidget()),