From 0183e6ef6479d478f7a0a4e1ca31bfa9bfc1cb1a Mon Sep 17 00:00:00 2001 From: Anton Efimchuk Date: Wed, 8 Jul 2026 14:13:00 +0200 Subject: [PATCH] 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 --- .../jetbrains/python/psi/types/TypeEvalContextImpl.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/python/python-psi-impl/src/com/jetbrains/python/psi/types/TypeEvalContextImpl.kt b/python/python-psi-impl/src/com/jetbrains/python/psi/types/TypeEvalContextImpl.kt index af1a0e279d46..4f4e7409690d 100644 --- a/python/python-psi-impl/src/com/jetbrains/python/psi/types/TypeEvalContextImpl.kt +++ b/python/python-psi-impl/src/com/jetbrains/python/psi/types/TypeEvalContextImpl.kt @@ -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