Skip to content

f-ohler/types-lxml

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

260 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyPI version Supported Python Wheel

This repository contains external type annotations for lxml. It can be used by type-checking tools (currently supporting mypy and pyright) to check code that uses lxml, or used within IDEs like VSCode or PyCharm to facilitate development.

Improvements

There are lots of enhancements on top of lxml-stubs:

  • Main goal ① Completes annotation for at least 90% of publicly used lxml API. Besides various completed classes and methods, here are currently implemented extra submodules:
    • lxml.builder
    • lxml.html.builder
    • lxml.html.clean
    • lxml.html.html5parser
    • lxml.html.soupparser
    • lxml.sax
    • Check out project page for future plans and progress
  • Main goal ② All existing contributions reviewed thoroughly, bringing coherency of annotation across the whole package
    • Guarantees error free for pyright basic checking mode as well
    • Much more extensive test cases
  • Modernize package building infrastructure

Installation

From PyPI

This is the normal choice for most people:

pip install -U types-lxml 

If there is plan to use html submodule for external libraries (mainly lxml.html.html5parser and lxml.html.soupparser), please install extra dependencies instead:

pip install -U types-lxml[extra] 

From downloaded wheel file

Head over to latest release in GitHub and download wheel file (with extension .whl), which can be installed in the same way as PyPI package:

pip install -U types-lxml*.whl 

Bleeding edge from GitHub

pip install -U git+https://github.com/abelcheung/types-lxml.git 

Special notes

There are two special stub-only classes that do not exist as concrete class in lxml:

  1. lxml.etree.ParserTarget
  2. lxml.etree.SmartStr

They are intended as helpers when writing code, wrapped under if TYPE_CHECKING: .... Please consult their docstring in stub files for detail, or if you are using IDEs, the docstring might have been formatted nicely for reference.

Stub docstring in PyCharm Documentation Tool

Stub docstring in VSCode mouseover tooltip

History

Type annotations for lxml were initially included in typeshed, but as it was still incomplete, it was decided to be ripped out as a separate project. The code was extracted by Jelle Zijlstra and moved to lxml-stubs repository using git filter-branch.

types-lxml is a fork of lxml-stubs that strives for completeness, so that most people would at least find it usable; while the the original lxml-stubs aims to be stable.

About

Type annotation for lxml striving for completeness

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 100.0%