A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Use upstream signature formatting code for pylsp (#5214)
Michał Krassowski012ed6ecdfa9
diff --git a/frontend/src/core/codemirror/language/languages/python.ts b/frontend/src/core/codemirror/language/languages/python.tsindex 3ed2d2bdbd..c0574637db 100644--- a/frontend/src/core/codemirror/language/languages/python.ts+++ b/frontend/src/core/codemirror/language/languages/python.ts@@ -133,6 +133,10 @@ const lspClient = once((lspConfig: LSPConfig) => {...ignoredRuffRules,],},+ signature: {+ formatter: config?.enable_ruff ? "ruff" : "black",+ line_length: 88,+ },},},};diff --git a/marimo/_server/lsp.py b/marimo/_server/lsp.pyindex 1ad98d6167..9b5fd60442 100644--- a/marimo/_server/lsp.py+++ b/marimo/_server/lsp.py@@ -14,8 +14,6 @@ from marimo._dependencies.dependencies import DependencyManagerfrom marimo._messaging.ops import Alertfrom marimo._server.utils import find_free_portfrom marimo._tracer import server_tracer-from marimo._types.ids import CellId_t-from marimo._utils.formatter import DefaultFormatter, FormatErrorfrom marimo._utils.paths import marimo_package_pathLOGGER = _loggers.marimo_logger()@@ -312,27 +310,3 @@ def any_lsp_server_running(config: MarimoConfig) -> bool:for server in language_servers.values())return (copilot_enabled is not False) or language_servers_enabled---if DependencyManager.pylsp.has():- from pylsp import hookimpl-- formatter = DefaultFormatter(line_length=88)-- def format_signature(signature: str) -> str:- try:- signature_as_func = f"def {signature.strip()}:\n pass"- dummy_cell_id = cast(CellId_t, "")- reformatted = formatter.format({dummy_cell_id: signature_as_func})[- dummy_cell_id- ]- signature = reformatted.removeprefix("def ").removesuffix(- ":\n pass"- )- except (ModuleNotFoundError, FormatError):- pass- return "```python\n" + signature + "\n```\n"-- @hookimpl- def pylsp_signatures_to_markdown(signatures: list[str]) -> str:- return format_signature("\n".join(signatures))diff --git a/pyproject.toml b/pyproject.tomlindex ccae68b9f9..d6535cb15c 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -78,9 +78,6 @@ homepage = "https://github.com/marimo-team/marimo"[project.entry-points."docstring_to_markdown"]marimo_converter = "marimo._utils.docs:MarimoConverter"-[project.entry-points."pylsp"]-marimo_plugin = "marimo._server.lsp"-[project.optional-dependencies]sql = ["duckdb>=1.0.0",@@ -117,7 +114,7 @@ dev = []lsp = [- "python-lsp-server>=1.10.0",+ "python-lsp-server>=1.13.0","python-lsp-ruff>=2.0.0",]@@ -195,7 +192,6 @@ dependencies = ["sqlglot>=23.4","sqlalchemy>=2.0.40","loro>=1.5.0",- "python-lsp-server>=1.12.1","pandas-stubs>=1.5.3.230321","pyiceberg>=0.9.0","litellm>=1.70.0",@@ -485,11 +481,6 @@ exclude = []warn_unused_ignores = false-[[tool.mypy.overrides]]-module = "pylsp"-# until https://github.com/python-lsp/python-lsp-server/pull/641 is released-follow_untyped_imports = true-[tool.pytest.ini_options]minversion = "6.0"addopts = "-ra -q -v --ignore tests/_cli/ipynb_data --ignore tests/_ast/codegen_data --ignore tests/_ast/app_data"