--- id: types-lxml version: "2026.2.16" license: Apache-2.0 license_treatment: permissive maintenance: active --- # types-lxml — Complete lxml external type annotation License: permissive · Maintenance: active · Downloads: 3.8M/mo ## 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 above — verify before relying. Provides complete external type annotations for lxml, enabling static type checking and IDE support for code using lxml's XML and HTML processing functionality. 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 pip install types-lxml uv add types-lxml poetry add types-lxml ## Installing types-lxml 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. 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') Requires Python 3.9 or later. Mypy plugin requires explicit configuration in mypy config file to enable. 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_current - Install friction: low - Maintenance: active - Downloads: 3.8M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags lxml type stubs, lxml type annotations, static type checking xml, lxml mypy plugin, type hints for lxml, lxml ide support, lxml type hints, type-stubs, lxml, static-analysis [View on SkillFed](https://skillfed.io/packages/types-lxml) · [View on PyPI](https://pypi.org/project/types-lxml/)