Skip to content

Commit 2e3c76e

Browse files
committed
docs: update README on current status
1 parent 9325c33 commit 2e3c76e

1 file changed

Lines changed: 38 additions & 38 deletions

File tree

README.md

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
## Important note
77

88
- Upcoming release:
9-
- Support for [`ty` type checker from Astral](https://docs.astral.sh/ty/) in progress
9+
- Support for [`pyrefly` type checker](https://pyrefly.org/)
10+
- New `mypy` plugin that mimics [`XMLParser.set_element_class_lookup()` behavior](https://github.com/abelcheung/types-lxml/wiki/Using-specialised-class-directly#no-automatic-change-of-subscript)
1011

1112
- Since `2025.11.25`:
1213
- [PEP 800 support](https://peps.python.org/pep-0800/), thus only compatible with newest type checkers as of Oct 2025
@@ -19,52 +20,32 @@
1920
- `BeautifulSoup4` package is added as dependency to utilise its inline annotation, thus dropping `types-beautifulsoup4` dependency.
2021
- Fixes compatibility with older versions of type checkers, as well as `mypy` 1.14+.
2122

22-
- Since `2025.02.24`:
23-
- Add [`basedpyright`](https://github.com/DetachHead/basedpyright) type checker support (an enhanced fork of `pyright`)
24-
25-
- Since `2024.11.08`:
26-
- `pyright` and `vscode` users will [receive warnings](#warnings-for-exception-and-wrong-code) if certain `lxml` API usage would result in exception or undesirable runtime behavior.
27-
- It is possible to [verify release files](#release-file-attestation) indeed come from GitHub and not maliciously altered.
2823

2924
## Introduction
3025

31-
This repository contains [external type annotations](https://peps.python.org/pep-0561/) for [`lxml`](http://lxml.de/). It can be used by [type-checking tools](#goal---support-multiple-type-checkers) to check code that uses `lxml`, or used within IDEs like [VSCode](https://code.visualstudio.com/) to facilitate development.
26+
This repository contains [external type annotations](https://peps.python.org/pep-0561/) for [`lxml`](http://lxml.de/). It can be used by [type-checking tools](#goal---support-multiple-type-checkers) to check code that uses `lxml`, or used within IDEs like [Visual Studio Code](https://code.visualstudio.com/) to facilitate development.
3227

3328
## Goal ① : Completion
3429

35-
Now the coverage of `lxml` submodules is complete (unless intentionally rejected, see further below), thus no more [considered as `partial`](https://peps.python.org/pep-0561/#partial-stub-packages):
36-
- [x] `lxml.etree`
37-
- [x] `lxml.html`
38-
- [x] `lxml.html.builder`
39-
- [x] `lxml.html.clean` (already removed in lxml 5.2.0, this project will follow suite in future)
40-
- [x] `lxml.html.diff`
41-
- [x] `lxml.html.html5parser`
42-
- [x] `lxml.html.soupparser`
43-
- [x] `lxml.isoschematron`
44-
- [x] `lxml.objectify`
45-
- [x] `lxml.builder`
46-
- [x] `lxml.cssselect`
47-
- [x] `lxml.sax`
48-
- [x] `lxml.ElementInclude`
49-
50-
Following submodules will not be implemented due to irrelevance to type checking or other reasons:
30+
Implementation is complete since 1Q 2003, thus no more [considered as `partial`](https://peps.python.org/pep-0561/#partial-stub-packages). Following submodules intentionally not implemented due to irrelevance to type checking or other reasons:
5131

5232
- `lxml.etree.Schematron` (obsolete and superseded by `lxml.isoschematron`)
53-
- `lxml.usedoctest`
54-
- `lxml.html.usedoctest`
33+
- `lxml.usedoctest` (for testing only)
34+
- `lxml.html.usedoctest` (for testing only)
5535
- `lxml.html.formfill` (shouldn't have existed, this would belong to HTTP libraries like `requests` or `httpx`)
5636

57-
Check out [project page](https://github.com/abelcheung/types-lxml/projects) for future plans and progress.
58-
5937
## Goal ② : Support multiple type checkers
6038

6139
Currently the annotations are validated for following type checkers:
6240

63-
- [`basedpyright`](https://github.com/DetachHead/basedpyright), version 1.31.6 or above
64-
- [`pyright`](https://github.com/microsoft/pyright), version 1.1.406 or above
65-
- [`mypy`](https://github.com/python/mypy), version 1.18.1 or above
41+
| Name | Version |
42+
| --- | :-- |
43+
| [`basedpyright`](https://github.com/DetachHead/basedpyright) | ≥ 1.31.6 |
44+
| [`mypy`](https://github.com/python/mypy) | ≥ 1.18.1 |
45+
| [`pyrefly`](https://pyrefly.org/) | ≥ 0.46.3 |
46+
| [`pyright`](https://github.com/microsoft/pyright) | ≥ 1.1.406 |
6647

67-
`pyright` and `basedpyright` are recommended for their greater flexibility and early adoption of newer type checking features. In the future, there is plan to bring even more type checker support.
48+
`pyright` and `basedpyright` are recommended for their greater flexibility, maturity and early adoption of newer type checking features. In the future, there is plan to bring even more type checker support (such as `ty` or `zuban`).
6849

6950
## Goal ③: Review and test suite
7051

@@ -83,15 +64,17 @@ This package tries to bring type annotation specific docstrings for some classes
8364

8465
#### Warnings for exception and wrong code
8566

86-
`pyright` (and therefore `vscode`) users receive additional benefit of being forewarned when their lxml code will likely cause undesirable runtime behavior or outright exception.
67+
![image showing deprecation warning](https://github.com/user-attachments/assets/6ab30a54-60e7-4e34-932a-2ac2e253c669)
68+
69+
`pyright` and `basedpyright` users receive additional benefit of being forewarned when their lxml code will likely cause undesirable runtime behavior or outright exception.
8770
- [#64](https://github.com/abelcheung/types-lxml/issues/64) covers one such example where such warnings are warrented.
8871
- Another example is `html.html5parser` submodule functions causing exception when `str` input and `guess_charset` parameter are used together.
8972

73+
Similarly their corresponding Visual Studio Code extensions would display visual cue when such problematic usage is encountered, as shown in above screenshot.
74+
9075
> [!NOTE]
9176
> This feature makes use of [`@deprecated` decorator](https://typing.python.org/en/latest/spec/directives.html#deprecated) from Python 3.13. `mypy` disables such warnings by default, and need to be [turned on explicitly](https://mypy.readthedocs.io/en/stable/error_code_list2.html#check-that-imported-or-used-feature-is-deprecated-deprecated).
9277
93-
![image showing deprecation warning](https://github.com/user-attachments/assets/6ab30a54-60e7-4e34-932a-2ac2e253c669)
94-
9578
#### Class inheritance change
9679

9780
Current annotations are geared towards convenience for programmers' convenience instead of absolute logical 'correctness'. The [deviation of class inheritance](https://github.com/abelcheung/types-lxml/wiki/Element-inheritance-change) for `HtmlComment` and friends is one prominent example.
@@ -107,10 +90,27 @@ The normal choice for most people is to fetch package from PyPI, like:
10790

10891
In the unlikely case PyPI is down, one can directly download wheel from [latest release in GitHub](https://github.com/abelcheung/types-lxml/releases/latest), and then perform installation as local file.
10992

110-
As convenience, it is possible to pull type checker directly [with extras](https://peps.python.org/pep-0508/#extras):
93+
As convenience, it is possible to [pull development related packages](https://peps.python.org/pep-0508/#extras). This helps when you want to submit PR on bugs or features:
94+
95+
uv pip install -U types-lxml[dev]
96+
pip install -U types-lxml[dev]
11197

112-
uv pip install -U types-lxml[pyright]
113-
pip install -U types-lxml[mypy]
98+
The stub package supports all Python versions since 3.9. But if you want to create PR and test your changes, Python 3.10 is needed.
99+
100+
### Mypy plugin usage
101+
102+
Mypy plugin bundled with this stub package needs to be explicitly turned on from config. Add these two lines under `[mypy]` global section if you're using INI file:
103+
104+
```ini
105+
plugins =
106+
mypy_plugin_lxml.main
107+
```
108+
109+
Alternatively, add this under `[tool.mypy]` section for `pyproject.toml`:
110+
111+
```toml
112+
plugins = ["mypy_plugin_lxml.main"]
113+
```
114114

115115
### Choosing the build
116116

0 commit comments

Comments
 (0)