settings: Remove auxiliary Content types where possible (#16744)

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-09-10 22:59:10 -04:00 committed by GitHub
parent 8f28445612
commit ccf6f27b8f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
49 changed files with 843 additions and 696 deletions

View file

@ -6,8 +6,10 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use settings::{Settings, SettingsSources};
#[derive(Debug, Default)]
#[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
#[serde(default)]
pub struct JupyterSettings {
/// Default kernels to select for each language.
pub kernel_selections: HashMap<String, String>,
}
@ -20,26 +22,10 @@ impl JupyterSettings {
}
}
#[derive(Clone, Serialize, Deserialize, JsonSchema, Debug)]
pub struct JupyterSettingsContent {
/// Default kernels to select for each language.
///
/// Default: `{}`
pub kernel_selections: Option<HashMap<String, String>>,
}
impl Default for JupyterSettingsContent {
fn default() -> Self {
JupyterSettingsContent {
kernel_selections: Some(HashMap::new()),
}
}
}
impl Settings for JupyterSettings {
const KEY: Option<&'static str> = Some("jupyter");
type FileContent = JupyterSettingsContent;
type FileContent = Self;
fn load(
sources: SettingsSources<Self::FileContent>,
@ -51,10 +37,8 @@ impl Settings for JupyterSettings {
let mut settings = JupyterSettings::default();
for value in sources.defaults_and_customizations() {
if let Some(source) = &value.kernel_selections {
for (k, v) in source {
settings.kernel_selections.insert(k.clone(), v.clone());
}
for (k, v) in &value.kernel_selections {
settings.kernel_selections.insert(k.clone(), v.clone());
}
}