types-lxml
Complete lxml external type annotation
Decision gist · record as of 2026-08-14
Yes. types-lxml is actively maintained, has no known vulnerabilities, installs with low friction, and is essential for any project using lxml that wants static type checking. The Apache-2.0 license poses no restriction. Install it if you use lxml and rely on type checking or IDE support.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later.
- Mypy plugin requires explicit configuration in mypy config file to enable.
- Low friction installation as a pure-Python wheel.
License · maintenance · safety
Apache-2.0 (permissive) — Apache-2.0 permissive license allows use in most projects without significant restrictions. Safe for both open-source and commercial codebases.
last release 2026-02-17 (178 days) · last repo commit 2026-06-29 · 84 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 3,813,233 downloads/mo, #2,492 on PyPI
Alternatives
Verify before relying
pip install types-lxml
# In mypy.ini or pyproject.toml, enable the plugin:
# [mypy]
# plugins = mypy_plugin_lxml.main
import lxml.etree as etree
root = etree.Element('root')- Whether the package's mypy plugin is required for basic type checking or only for advanced features like XMLParser.set_element_class_lookup() behavior.
- Performance impact of enabling the mypy plugin on type-check times for large projects.
What it is and what it does
types-lxml is a stub package that provides complete external type annotations for the lxml library, allowing Python type checkers and IDEs to understand and validate code that uses lxml's XML and HTML processing APIs. It works with multiple type checkers—mypy, pyright, basedpyright, pyrefly, and ty—and includes a mypy plugin that adds specialized type-checking behavior for lxml-specific patterns.
The package is built around four goals: complete annotation coverage (no longer marked as partial), support for multiple type checkers, extensive review and testing against real runtime behavior, and developer-friendly features like contextual docstrings and warnings for problematic usage patterns. It includes both a standard build and a multi-subclass variant for projects that create multiple lxml element subclasses, and supports Python 3.9 through 3.14.
Use it for
- Enable static type checking in IDEs and CI pipelines for projects using lxml for XML or HTML parsing.
- Catch type errors in lxml code before runtime, such as incorrect method calls or type mismatches.
- Get IDE autocomplete and inline documentation for lxml APIs in Visual Studio Code and other editors.
- Use the mypy plugin to enforce correct patterns for lxml element class lookups and inheritance.
- Validate lxml code against multiple type checkers to ensure broad compatibility.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes.
types-lxml is actively maintained, has no known vulnerabilities, installs with low friction, and is essential for any project using lxml that wants static type checking. The Apache-2.0 license poses no restriction. Install it if you use lxml and rely on type checking or IDE support.
Install
types-lxml on PyPI
Before you install
Low friction installation as a pure-Python wheel. Actively maintained with recent releases; last commit 2026-06-29. Supports current Python versions (3.9–3.14) and works with multiple type checkers including mypy, pyright, basedpyright, pyrefly, and ty.
Requires Python 3.9 or later. Mypy plugin requires explicit configuration in mypy config file to enable.
License in practice
Apache-2.0 permissive license allows use in most projects without significant restrictions. Safe for both open-source and commercial codebases.
Quickstart
pip install types-lxml
# In mypy.ini or pyproject.toml, enable the plugin:
# [mypy]
# plugins = mypy_plugin_lxml.main
import lxml.etree as etree
root = etree.Element('root')
Verify before relying
- Whether the package's mypy plugin is required for basic type checking or only for advanced features like XMLParser.set_element_class_lookup() behavior.
- Performance impact of enabling the mypy plugin on type-check times for large projects.
Package facts
| License | Apache-2.0 permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 4 packagestyping_extensionscssselectbeautifulsoup4types-html5lib |
| Maintenance | Actively maintained 178 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 3,813,233 / month, #2,492 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableIntended Audience :: DevelopersOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9Typing :: Stubs Only |
Evidence: types_lxml-2026.2.16-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “lxml type stubs”
- types-lxmlProvides complete external type annotations for lxml, enabling static…
- lxml-stubsProvides type annotations for the lxml package to enable static type…
- types-assertpyProvides type stubs enabling static type checkers like mypy and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Markup packages
PyYAML parses and emits YAML 1.1 data format, enabling serialization and deserialization of configuration files and Python objects to and from human-readable YAML text.
A Python markdown parser that converts markdown to HTML following the CommonMark specification, with support for plugins and custom syntax rules.
Install it if you need reliable markdown-to-HTML conversion.
Beautiful Soup parses HTML and XML documents into a navigable tree, providing Pythonic methods to search, iterate, and modify the parsed content.
Install it if you need to parse or extract data from markup documents.
et_xmlfile writes large XML files with minimal memory overhead by serializing elements to disk as they are created, rather than holding the entire tree in memory.
Install it if incremental XML writing fits your use case; skip it if your XML documents are small or you already use lxml.
Parses and edits TOML files while preserving formatting, comments, and structure, then serializes them back with layout intact.
Install it if you're building tools that touch TOML files and user readability of the source matters.
Parses Python docstrings in ReST, Google, Numpydoc, and Epydoc formats, extracting structured information like descriptions, parameters, return types, and exceptions.
Install it if you need to programmatically read and extract structured data from Python docstrings.
See also lxml-stubs · types-Pygments · types-setuptools · types-openpyxl · types-beautifulsoup4 · types-braintree · types-yt-dlp · types-dateparser · types-gevent · basedpyright