types-Pygments
Typing stubs for Pygments
What it is and what it does
types-Pygments is a type stub package that adds static type annotations for the Pygments syntax highlighting library. It allows type checkers like mypy and pyright to understand and validate code that imports and uses Pygments, catching type-related errors at check time rather than runtime.
The package is maintained as part of typeshed, the canonical repository of type stubs for the Python ecosystem. It targets Pygments 2.20.* and is marked as partial, meaning some annotations may be incomplete—contributions to improve coverage are welcomed through the typeshed project itself.
Use it for:
- Enable mypy or pyright to type-check code that uses Pygments for syntax highlighting.
- Catch type errors in Pygments API calls during static analysis before running code.
- Provide IDE autocomplete and inline type information for Pygments functions and classes.
- Integrate Pygments into a codebase with strict type checking enabled.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides type hints for the Pygments syntax highlighting library, enabling static type checkers to validate code that uses Pygments.
Yes, if you use Pygments and run a static type checker. It has no runtime cost, no dependencies, and is actively maintained by typeshed. Install it alongside Pygments to enable type checking. If you do not use a type checker or do not use Pygments, it provides no value.
Install
types-pygments on PyPI
pip
pip install types-pygmentsuv
uv add types-pygmentspoetry
poetry add types-pygmentsInstalling types-Pygments
Before you install
Low install friction with no runtime dependencies. Actively maintained as part of typeshed, with a release 17 days old and recent upstream commits.
License in practice
Licensed under Apache-2.0 (permissive), imposing no restrictions on use or distribution.
Quickstart
pip install types-Pygments
import pygments
from pygments.lexers import get_lexer_by_name
lexer = get_lexer_by_name('python')
Requires Python 3.10 or later.
Verify before relying
- Whether coverage of Pygments 2.20.* APIs is sufficient for your specific use case, given the package is marked as partial.
- Compatibility with type checkers beyond mypy 2.3.0, pyright 1.1.411, and ty 0.0.59.
Package facts
| License | Apache-2.0 (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 17 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,201,764/month — #2,704 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: types_pygments-2.20.0.20260728-py3-none-any.whl
Tags
More Text Processing packages
A drop-in replacement for Python's standard…
permissive · top 100 on PyPI
pyparsingpyparsing provides a library for building text…
permissive · top 1,000 on PyPI
docutilsDocutils converts plaintext documentation in…
unclear · top 1,000 on PyPI
RapidFuzzRapidFuzz provides fast fuzzy string matching…
permissive · top 1,000 on PyPI
tinycss2tinycss2 parses CSS strings into token and…
permissive · top 1,000 on PyPI
llama-parseLlamaParse parses complex documents (PDFs,…
permissive · top 1,000 on PyPI
types-peeweeProvides type annotations for the peewee ORM…
permissive · top 15,000 on PyPI
types-tensorflowProvides type hints for TensorFlow 2.18.0,…
permissive · top 15,000 on PyPI
types-yt-dlpProvides type hints for yt-dlp, enabling static…
permissive · top 15,000 on PyPI
types-pyinstallerProvides type stubs for pyinstaller, enabling…
permissive · top 15,000 on PyPI
types-grpcioProvides type stubs for the grpcio package,…
permissive · top 5,000 on PyPI
types-docutilsProvides type hints for the docutils library,…
permissive · top 5,000 on PyPI
types-braintreeProvides type hints for the braintree payment…
permissive · top 15,000 on PyPI
types-lxmlProvides complete external type annotations for…
permissive · top 5,000 on PyPI
types-openpyxlProvides type hints for openpyxl, enabling…
permissive · top 5,000 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI