PY-90789 gate notebook LSP support behind registry keys

Add a global Jupyter notebook LSP gate that keeps notebook document integration disabled by default and make Python LSP file support respect that gate from isPythonFile().

Also default notebook type evaluation back to the internal engine unless the dedicated notebook type-engine registry key is enabled, and cover both the disabled and enabled paths with targeted Python and notebook env tests.

IJ-MR-212495

GitOrigin-RevId: 3d7ae5ddaaac74d295d3bed75eb6a2bf636d2d87
This commit is contained in:
Anton Efimchuk
2026-07-09 09:22:19 +00:00
committed by intellij-monorepo-bot
parent a0f1b6d71a
commit 0183e6ef64
@@ -47,6 +47,9 @@ open class TypeEvalContextImpl internal constructor(
@ApiStatus.Internal
val typeEngine: PyTypeEngine? = constraints.myOrigin?.let {
if (isNotebookExternalTypeEngineDisabled(it)) {
return@let null
}
ModuleUtilCore.findModuleForFile(it)
}?.let { module ->
PyTypeEngineProvider.createTypeResolver(module)
@@ -87,6 +90,12 @@ open class TypeEvalContextImpl internal constructor(
return constraints.myAllowStubToAST && !element.inPyiFile() || inOrigin(element)
}
private fun isNotebookExternalTypeEngineDisabled(origin: PsiFile): Boolean {
val realFile = origin.originalFile.virtualFile ?: return false
return realFile.extension.equals("ipynb", ignoreCase = true) &&
!Registry.`is`("python.lsp.type.engine.notebooks", false)
}
@ApiStatus.Internal
override fun isExternal(): Boolean = constraints.myIsExternal