The list of changes [since last release](https://github.com/abelcheung/types-lxml/compare/2023.02.11...2023.3.28) is huge, be it visible by users or not.
Breaking changes
- Class inheritance of `html.HtmlComment` and friends have changed to deviate from source code. Now they are 'thought' to inherit from `html.HtmlElement` within stubs, like the XML `etree._Element` counterpart. [Refer to wiki document](https://github.com/abelcheung/types-lxml/wiki/Element-inheritance-change) on how and why this change is done.
- Shelved custom parser target support (custom parser target is used when initiating XML / HTML parsers with `target=` argument), as current python typing system is deemed insufficient to get it working without plugins.
- Stub package only depends on other stub packages, following behavior of typeshed distributed stubs. This means `lxml` is no longer pulled in when installing `types-lxml`.
- `etree.SmartStr` reverted back to [its original class name](https://github.com/abelcheung/types-lxml/wiki/Smart-string-usage)
- `etree._ErrorLog` is now made a function that generates `etree._ListErrorLog` (despite the fact that it is a class in source code), according to actual created instance type
Significant changes / completion
- Completed following submodules and parts, thus removing [the partial status](https://peps.python.org/pep-0561/#partial-stub-packages) of `types-lxml` package:
- `lxml.etree` proper:
- [x] XSLT related classes / functions
- [x] XML:ID support
- [x] External [document and URI resolving](https://lxml.de/resolvers.html)
- [x] XInclude support
- [x] XPath and XSLT [extension function registry](https://lxml.de/extensions.html)
- [x] Error log and reporting, along with numerous bug fixes
- [x] `etree.iterparse` and `etree.iterwalk`
- [x] Various `ElementClassLookup` types
- [x] `lxml.objectify`
- [x] Includes all `DataElement` subtypes and type annotation support
- [x] `lxml.isoschematron`
- When subclassing XML elements, now most of its methods can be inherited without overriding output element type.
Smaller changes
- More extensive usage of Python 3.9-3.11 typing features, this is possible since `types-lxml` is external stub package and doesn't affect source code. Such as:
- Marking string constants as `LiteralString` ([PEP 675](https://peps.python.org/pep-0675/))
- Make type aliases more explicit ([PEP 613](https://peps.python.org/pep-0613/))
- Convenient `Self` when declaring methods ([PEP 673](https://peps.python.org/pep-0673/))
- Both `mypy` and `pyright` type checkers have strict mode turned on when verifying stub source
- `_Element.sourceline` property becomes read-only
- Re-added most deprecated methods in various places, with help from provisional [PEP 702](https://peps.python.org/pep-0702/) support (`deprecated`) in `pyright`
- Incorporate more docstring from official `lxml` classes, in case IDEs can display them in user interface.
- Force `_XPathEvaluatorBase` subclasses to make `__call__` available, by explicitly declaring it as abstract method within `_XPathEvaluatorBase`
- Removal of `http.open_http_urllib`, which is only intended as a fallback callback function for `html.submit_form()` without user intervention
- `libxml2` error constants become integer `enum` in stub
- Warn userland usage of dummy `etree.PyErrorLog.copy()`, because it is only intended for smoother internal `lxml` error handling.
Bug fixes
- File reading source (used in `file=` argument in `parse()` and friends) requirement relaxed
- `html.(X)HtmlParser` `__init__` was missing some arguments
- Convert `iter*` methods of Elements and some tag cleanup functions into `overload`, to better reflect its original intended arguments usage
- `etree.ElementBase` and similar public base element classes lacked `__init__`
- Setting of `etree.DocInfo` text properties now accepts `bytes`
- `name=` argument of `html.HtmlElementClassLookup()` doesn't accept `None`
- Concerning `_Comment`, `_Entity`, `_ProcessingInstruction`, and their subclasses
- `.tag` attribute now returns correct value (the basic etree element factory function)
- Users will be warned if they use these elements like normal XML `_Element` do, such as treating them as parent elements and insert children element into them