types-lxml icon indicating copy to clipboard operation
types-lxml copied to clipboard

Full PEP 695+696 support (after Autumn 2027)

Open abelcheung opened this issue 1 year ago • 2 comments

(Won't happen anytime soon, unless ditching mypy support right here and right now)

~With mypy 1.11 requirement present, the time is probably ripe for support of full type parameter syntax (def func[T](...)).~

abelcheung avatar Oct 02 '24 10:10 abelcheung

I'm too naïve, mypy isn't ready yet when bringing PEP696 into equation, even with newest mypy 1.12 and python 3.13:

lxml-stubs\etree\_element.pyi:229: error: Type parameter default types not supported when using Python 3.12 type parameter syntax [misc]
    class _ElementTree[E: _Element = _Element]:

Apparently still being worked on (python/mypy#14851). pyright does fine since 1.1.351 (or before).

abelcheung avatar Oct 15 '24 02:10 abelcheung

Turns out lack of PEP696 support is a lesser problem. mypy requires python 3.12 to type check code with new Generic syntax, and --python-version argument is ignored if the python interpreter running mypy isn't at least 3.12. This means project maintainers using types-lxml are forced to use py3.12 as minimum dependency, otherwise they can't type check their code.

Throwing mypy out of window isn't an option here; it would be a great disservice to those using this annotation package. The only other option is to wait till Python 3.11 is EOLed and make an excuse that we don't support EOLed python versions.

abelcheung avatar Oct 15 '24 18:10 abelcheung