@codemirror/lang-python

Python language support for the CodeMirror code editor, with highlighting, indentation, and autocompletion.

Library
npm
v6.2.1
42stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
26/100Needs Attention
Development Activity12
Maintenance0
Community20
Maturity60
Momentum12

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture85
Code Quality82
Innovation80
Learning Curve80

@codemirror/lang-python adds first-class Python editing to CodeMirror 6. It wraps the Lezer Python parser in a CodeMirror LanguageSupport, layering on syntax highlighting, context-aware indentation for blocks and continuation lines, code folding, and completion sources for both built-in globals and locally defined names.

Dropping the python() extension into an EditorView gives you a Python-aware editing surface without hand-rolling tokenizers or indentation heuristics. It is one of the official CodeMirror language packages, sharing the same architecture and release conventions as the rest of the ecosystem.

What You Get

  • A ready-to-use python() LanguageSupport extension for CodeMirror 6.
  • Syntax highlighting driven by the Lezer Python grammar.
  • Context-aware indentation for blocks, brackets, and continuation lines, including match/case, else/elif, and except handling.
  • Autocompletion for Python built-in globals, keywords, and locally defined names.
  • Code folding for functions, classes, collections, and multiline strings.

Common Use Cases

  • Building an in-browser Python code editor or REPL front-end.
  • Adding a Python editing mode to a documentation site, notebook, or teaching tool.
  • Powering code cells in a low-code or data-science web application.

Under The Hood

Architecture — The package is a thin, well-factored integration layer over the Lezer Python parser. src/python.ts defines pythonLanguage as an LRLanguage that configures the imported Lezer parser with indentNodeProp and foldNodeProp metadata; helper functions innerBody and indentBody walk the syntax tree to resolve Python’s whitespace-significant indentation, handling block bodies, match/case, and deindenting keywords. The exported python() factory returns a LanguageSupport bundling the language with two autocomplete data providers wired from src/complete.ts.

Tech Stack — Written entirely in TypeScript (100% of the source), it depends on @lezer/python and @lezer/common for parsing plus @codemirror/language, @codemirror/autocomplete, and @codemirror/state for editor integration. It builds to dual ESM/CJS output via the @codemirror/buildhelper toolchain (cm-buildhelper), ships type definitions, and is marked sideEffects: false for tree-shaking.

Code Quality — The codebase is compact (~12KB of source across python.ts and complete.ts) and idiomatic for the CodeMirror ecosystem, using a NodeWeakMap cache and a declarative gatherCompletions table keyed by node type to collect scoped definitions. Public APIs carry doc comments. Testing is present via a test-indent.ts suite run with cm-runtests, focused on the indentation logic that is the trickiest part of the package.

API Design — The public surface is minimal and ergonomic: importing python() and adding it to an editor’s extensions is the entire happy path, matching the uniform convention shared across all official CodeMirror language packages. Lower-level exports (pythonLanguage, globalCompletion, localCompletionSource) let advanced users compose custom behavior. The README documents each export with linked type references, keeping boilerplate near zero.

Used by 25 apps in this directory

Python
54%
Other

authentik

Authentication · Security

24,980

The self-hosted Identity Provider that replaces Okta, Auth0, and Entra ID with a unified SSO platform supporting SAML, OAuth2/OIDC, LDAP, RADIUS, and WebAuthn.

View details
92
Repo Health
81
Technical
68
Dependency
Built with
Python54%
TypeScript33%
Updated today
Python
64%
MIT

Flowfile

Data Engineering

341

Visual ETL that compiles to Polars — build pipelines on a canvas, export as standalone Python, and run anywhere without platform lock-in.

View details
83
Repo Health
81
Technical
66
Dependency
Built with
Python64%
Vue19%
TypeScript16%
Updated today
TypeScript
62%
Other

Flowise

Developer Tools · Automation · No Code Platforms

55,379

Drag-and-drop visual builder for AI agents, RAG pipelines, and multi-agent systems—deploy anywhere in minutes.

View details
91
Repo Health
77
Technical
64
Dependency
Built with
TypeScript62%
JavaScript27%
Updated 6 days ago
Rust
69%
Other

GitButler

Developer Tools · Devops · AI Development

21,531

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
68
Dependency
Built with
Rust69%
TypeScript18%
Svelte12%
Updated today
TypeScript
95%
Apache 2.0

InsForge

Developer Tools · Databases

12,741

The all-in-one, open-source backend platform purpose-built for AI coding agents — giving your agent database, auth, storage, edge functions, a model gateway, and compute to ship full-stack apps end-to-end.

View details
86
Repo Health
81
Technical
73
Dependency
Built with
TypeScript95%
Updated yesterday
TypeScript
69%
Apache 2.0

Laminar

AI Development · Monitoring

3,180

Open-source observability platform purpose-built for AI agents — trace, evaluate, debug, and monitor at scale with SQL access and real-time replay.

View details
85
Repo Health
76
Technical
70
Dependency
Built with
TypeScript69%
Rust29%
Updated yesterday
TypeScript
98%
Other

Langfuse

AI Development · Monitoring

33,366

Open source AI engineering platform for LLM observability, prompt management, evaluation, and debugging — self-host in minutes or use Langfuse Cloud.

View details
92
Repo Health
81
Technical
66
Dependency
Built with
TypeScript98%
Updated today
Python
51%
AGPL 3.0

LearnHouse

Learning Management · CMS

2,178

Open-source LMS with AI tutoring, real-time collaboration boards, live code execution, and built-in course monetization — self-hosted in minutes.

View details
89
Repo Health
77
Technical
67
Dependency
Built with
Python51%
TypeScript48%
Updated 3 days ago
Python
61%
Apache 2.0

marimo

Developer Tools · Data Engineering

22,393

A reactive Python notebook that eliminates hidden state, runs reproducibly, and deploys as a web app or script — stored as pure Python, built for the AI era.

View details
90
Repo Health
91
Technical
66
Dependency
Built with
Python61%
TypeScript37%
Updated today

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search