Repository: astral-sh/ruff
File: crates/ty_ide/src/completion.rs (Rust)

Code before:
        }
    }

    fn value_keyword(name: &str, ty: Type<'db>) -> Completion<'db> {
        Completion {
            name: name.into(),
            qualified: None,
            insert: None,
            ty: Some(ty),
            kind: Some(CompletionKind::Keyword),
            module_name: None,
            import: None,
            builtin: true,
            is_type_check_only: false,
            is_definitively_raisable: false,
            documentation: None,
        }
    }

    fn argument(name: &str, ty: Option<Type<'db>>, documentation: Option<&str>) -> Self {
        let insert = Some(format!("{name}=").into_boxed_str());
        let documentation = documentation.map(|d| Docstring::new(d.to_owned()));

        Completion {
            name: name.into(),
            qualified: None,
            insert,
            ty,
            kind: Some(CompletionKind::Variable),
            module_name: None,
            import: None,
            builtin: false,
            is_type_check_only: false,
            is_definitively_raisable: false,
            documentation,
        }
    }

    /// Returns true when this completion refers to the
    /// `NotImplemented` builtin.
    fn is_notimplemented(&self, db: &dyn Db) -> bool {
        let Some(ty) = self.ty else { return false };
        ty.is_notimplemented(db)
    }
}

/// The "kind" of a completion.
///
/// This is taken directly from the LSP completion specification:
/// <https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#completionItemKind>
///

Review comment (suggestion):
nit

```suggestion
        let documentation = documentation.clone().map(Docstring::new);
```

Code after:
            builtin: false,
            is_type_check_only: false,
            is_definitively_raisable: false,
            documentation: None,
        }
    }

    fn value_keyword(name: &str, ty: Type<'db>) -> Completion<'db> {
        Completion {
            name: name.into(),
            qualified: None,
            insert: None,
            ty: Some(ty),
            kind: Some(CompletionKind::Keyword),
            module_name: None,
            import: None,
            builtin: true,
            is_type_check_only: false,
            is_definitively_raisable: false,
            documentation: None,
        }
    }

    fn argument(name: &str, ty: Option<Type<'db>>, documentation: Option<&str>) -> Self {
        let insert = Some(format!("{name}=").into_boxed_str());
        let documentation = documentation.map(|d| Docstring::new(d.to_owned()));

        Completion {
            name: name.into(),
            qualified: None,
            insert,
            ty,
            kind: Some(CompletionKind::Variable),
            module_name: None,
            import: None,
            builtin: false,
            is_type_check_only: false,
            is_definitively_raisable: false,
            documentation,
        }
    }

    /// Returns true when this completion refers to the
    /// `NotImplemented` builtin.
    fn is_notimplemented(&self, db: &dyn Db) -> bool {
        let Some(ty) = self.ty else { return false };
        ty.is_notimplemented(db)
    }
}

/// The "kind" of a completion.