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

Type stubs for the lxml package

Results 26 lxml-stubs issues
Sort by recently updated
recently updated
newest added

For Nixpkgs we see an error for Python 3.11 and Python 3.12 with pytest 7.4.4 and mypy-plugins 3.0.0. ```bash ============================= test session starts ============================== platform linux -- Python 3.11.7, pytest-7.4.4,...

```py from lxml.etree import XML assert XML(b"").attrib == {'foo': 'bar'} ``` mypy complains about this code, even though it works at runtime: ``` Non-overlapping equality check (left operand type: "_Attrib",...

Fix the following mypy error: ``` lib/galaxy/tool_util/linters/xsd.py:28: error: "_ErrorLog" has no attribute "__iter__" (not iterable) [attr-defined] for error in xsd.error_log: ^~~~~~~~~~~~~ ``` xref: https://github.com/galaxyproject/galaxy/pull/17081/files#r1490662640

In etree.pyi:219 the type definition of sourceline is `sourceline = ... # Optional[int]`, which gives me an error using pylance. It works when changed to `sourceline = ... # type:...

`_Element.clear()` takes a boolean parameter named `keep_tail`. This parameter does not exist in the stdlib ElementTree, but does exist in lxml.etree. See https://lxml.de/api/lxml.etree._Element-class.html#clear The docstring for `clear` in lxml.etree reads...

`nsmap` argument of [Element](https://github.com/lxml/lxml-stubs/blob/master/lxml-stubs/etree.pyi#L467) function is of type `Optional[_NSMapArg]` where `_NSMapArg` is `Mapping[str, str]`. But according to the documentation [here](https://lxml.de/tutorial.html#namespaces) namespace key for the default namespace supposed to be `None`:...

I am using an error reporting approach similar to [Example #1 on this page](https://www.programcreek.com/python/example/78618/lxml.etree.DocumentInvalid): ``` except etree.DocumentInvalid as exc: for error in exc.error_log: logger.error(f"{error.filename}:{error.line}: {error.message}") ``` However, this gives: ```...

Per the `lxml` source code, `fragments_fromstring` should return a List: https://github.com/lxml/lxml/blob/d5593c118856d3eba1eef181e3e0c666ded11f35/src/lxml/html/__init__.py#L770-L772 However, the type stubs here declare it as returning an `_Element`: https://github.com/lxml/lxml-stubs/blob/0a9b6099dd39b298fd0ff897dbcd4fed632d8776/lxml-stubs/html/__init__.pyi#L75-L81

Right now `_Element.text` is typed as `Optional[Union[str, bytes]]`. However according to the [lxml FAQ]:(https://lxml.de/3.6/FAQ.html): > In Python 3, lxml always returns Unicode strings for text and names, as does ElementTree....