astral-sh/ruff · error
`python_extension` is not expected to be combined with the i
Error message
`python_extension` is not expected to be combined with the initialization options as it's only set by the ty VS Code extension in the `workspace/configuration` request.
What it means
The `python_extension` server option is special: it is never part of initialization options and is only populated from the `workspace/configuration` request issued by the ty VS Code extension. Its `Combine` implementation (used to merge layered configuration) therefore panics if it is ever asked to combine, because that would mean someone put `python_extension` in the wrong configuration layer.
Source
Thrown at crates/ty_server/src/session/options.rs:526
impl Experimental {
fn into_settings(self) -> ExperimentalSettings {
// `use_uv` is resolved separately before project discovery because changing it requires
// rebuilding every project database.
let Self { use_uv: _ } = self;
ExperimentalSettings {}
}
}
#[derive(Clone, Debug, Serialize, Deserialize, Default, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct PythonExtension {
active_environment: Option<ActiveEnvironment>,
}
impl Combine for PythonExtension {
fn combine_with(&mut self, _other: Self) {
panic!(
"`python_extension` is not expected to be combined with the initialization options as \
it's only set by the ty VS Code extension in the `workspace/configuration` request."
);
}
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ActiveEnvironment {
executable: PythonExecutable,
#[deprecated]
environment: Option<PythonEnvironment>,
version: Option<EnvironmentVersion>,
}
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub(crate) struct EnvironmentVersion {View on GitHub (pinned to 26f38c119c)
Solutions
- Remove the `python_extension` key from your LSP initializationOptions.
- Let the ty VS Code extension supply those settings via the `workspace/configuration` request instead of passing them at initialization.
- Put only supported workspace settings (e.g. python path, interpreter) in initializationOptions.
Example fix
// before
initializationOptions = { python_extension: { activeEnvironment: "venv" } };
// after
initializationOptions = {}; // extension settings come via workspace/configuration Defensive patterns
Strategy: validation
Validate before calling
// Client-side check before sending initializationOptions:
const forbidden = ['python_extension'];
for (const key of forbidden) {
if (key in initializationOptions) {
throw new Error(`${key} must come via workspace/configuration, not initializationOptions`);
}
} Prevention
- Never place python_extension in initializationOptions.
- Let the ty VS Code extension own that settings section via workspace/configuration.
- Review LSP client configs (launch.json, nvim lspconfig) for stray server-only keys.
When it happens
Trigger: Sending a `python_extension` section inside `initializationOptions` when starting the ty LSP server, so the session tries to combine it with client/extension settings via `Combine::combine_with`.
Common situations: Users or client authors copying the extension's settings into initializationOptions in launch configurations (e.g. VS Code launch.json, Neovim LSP setup); misconfigured LSP client adapters passing all settings at init time.
Related errors
- InternalError
- InternalError
- Server notebook document could not be converted to ty's note
- tried to set QoS of thread which has opted out of QoS (os er
- tried to get QoS of thread which has opted out of QoS
AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05).
Data as JSON: /api/errors/938065069e3111d4.
Report an issue: GitHub.