Welcome to check out types-lxml if any late comer are still interested. I have done quite some gap filling over the years, so now it can be considered completed for all major submodules: lxml.etree
, lxml.html
and lxml.objectify
. The next release after March 2023 should cover everything except lxml.isoschematron
, which does very powerful schema validation, but few people would use it.
I’ve used stubgen
to create stub type definitions and filling in “any”-types
This is actually the correct approach if it's not lxml; creating template from mypy
stubgen
is the starting point for many stub files. But lxml is mostly written in Cython, for which stubgen do not have perfect support yet. Besides, as OP noted, this is a python 2.0 era module, and author uses function arguments in a quite polymorphous way. There are lots of unique challenges annotating lxml, as lxml is essentially a python interface for libxml
and libxslt
in its core.
As an example, the support of both unicode
and bytes
input complicates matter too; this is the same difficulty found when annotating xml.etree
bundled with python, but in a much greater magnitude.
[Disclaimer: I'm maintainer of types-lxml
package mentioned above]