diff --git a/lxml-stubs/_types.pyi b/lxml-stubs/_types.pyi index fdee512..20ba0c6 100644 --- a/lxml-stubs/_types.pyi +++ b/lxml-stubs/_types.pyi @@ -1,3 +1,4 @@ +import sys from _typeshed import SupportsRead, SupportsWrite, _KT_co, _VT_co from os import PathLike from typing import ( @@ -10,7 +11,11 @@ from typing import ( Protocol, TypeVar, ) -from typing_extensions import TypeAlias + +if sys.version_info >= (3, 10): + from typing import TypeAlias +else: + from typing_extensions import TypeAlias from .etree import QName, _Element, _ElementTree diff --git a/lxml-stubs/etree/_docloader.pyi b/lxml-stubs/etree/_docloader.pyi index e081dd6..4a89252 100644 --- a/lxml-stubs/etree/_docloader.pyi +++ b/lxml-stubs/etree/_docloader.pyi @@ -1,7 +1,12 @@ +import sys from _typeshed import SupportsRead from abc import ABCMeta, abstractmethod from typing import Any, final, type_check_only -from typing_extensions import Self + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self from .._types import _AnyStr diff --git a/lxml-stubs/etree/_element.pyi b/lxml-stubs/etree/_element.pyi index 7705c28..c0505f1 100644 --- a/lxml-stubs/etree/_element.pyi +++ b/lxml-stubs/etree/_element.pyi @@ -1,6 +1,16 @@ +import sys from _typeshed import _T from typing import Any, Generic, Iterable, Iterator, Literal, Mapping, overload -from typing_extensions import Never, Self, deprecated + +if sys.version_info >= (3, 11): + from typing import Never, Self +else: + from typing_extensions import Never, Self + +if sys.version_info >= (3, 13): + from typing import deprecated +else: + from typing_extensions import deprecated from .. import _types as _t from ..cssselect import _CSSTransArg @@ -318,8 +328,9 @@ class _ElementTree(Generic[_t._ET_co]): self, _xslt: _t._ElementOrTree, /, - extensions: _t.SupportsLaxedItems[tuple[_t._AnyStr, _t._AnyStr], XSLTExtension] - | None = ..., + extensions: ( + _t.SupportsLaxedItems[tuple[_t._AnyStr, _t._AnyStr], XSLTExtension] | None + ) = ..., access_control: XSLTAccessControl | None = ..., *, # all keywords are passed to XSLT.__call__ profile_run: bool = ..., @@ -354,9 +365,11 @@ class _Attrib: # explicitly checks for dict and _Attrib def update( self, - sequence_or_dict: _Attrib - | dict[Any, Any] # Compromise with MutableMapping key/val invariance - | Iterable[tuple[_t._AttrName, _t._AttrVal]], + sequence_or_dict: ( + _Attrib + | dict[Any, Any] # Compromise with MutableMapping key/val invariance + | Iterable[tuple[_t._AttrName, _t._AttrVal]] + ), ) -> None: ... # Signature is pop(self, key, *default), yet followed by runtime # check and raise exception if multiple default argument is supplied diff --git a/lxml-stubs/etree/_iterparse.pyi b/lxml-stubs/etree/_iterparse.pyi index 0fdfcb0..c98b7da 100644 --- a/lxml-stubs/etree/_iterparse.pyi +++ b/lxml-stubs/etree/_iterparse.pyi @@ -1,6 +1,16 @@ +import sys from _typeshed import SupportsRead, _T_co from typing import IO, Iterable, Iterator, Literal, overload -from typing_extensions import LiteralString, TypeAlias + +if sys.version_info >= (3, 10): + from typing import TypeAlias +else: + from typing_extensions import TypeAlias + +if sys.version_info >= (3, 11): + from typing import LiteralString +else: + from typing_extensions import LiteralString from .._types import ( SupportsLaxedItems, diff --git a/lxml-stubs/etree/_module_func.pyi b/lxml-stubs/etree/_module_func.pyi index 8fa09f4..1b49cb6 100644 --- a/lxml-stubs/etree/_module_func.pyi +++ b/lxml-stubs/etree/_module_func.pyi @@ -1,5 +1,15 @@ +import sys from typing import Any, Iterable, Literal, final, overload -from typing_extensions import TypeGuard, deprecated + +if sys.version_info >= (3, 10): + from typing import TypeGuard +else: + from typing_extensions import TypeGuard + +if sys.version_info >= (3, 13): + from typing import deprecated +else: + from typing_extensions import deprecated from .._types import ( _ET, diff --git a/lxml-stubs/etree/_module_misc.pyi b/lxml-stubs/etree/_module_misc.pyi index 7d7fb19..ffad172 100644 --- a/lxml-stubs/etree/_module_misc.pyi +++ b/lxml-stubs/etree/_module_misc.pyi @@ -2,9 +2,14 @@ # lxml.etree helper classes, exceptions and constants # +import sys from abc import ABCMeta, abstractmethod from typing import overload -from typing_extensions import LiteralString + +if sys.version_info >= (3, 11): + from typing import LiteralString +else: + from typing_extensions import LiteralString from .._types import _AnyStr, _ElementOrTree, _TagName from ._dtd import DTD diff --git a/lxml-stubs/etree/_nsclasses.pyi b/lxml-stubs/etree/_nsclasses.pyi index 51d30f6..b2d3dca 100644 --- a/lxml-stubs/etree/_nsclasses.pyi +++ b/lxml-stubs/etree/_nsclasses.pyi @@ -1,3 +1,4 @@ +import sys from _typeshed import _KT, _T, _VT from typing import ( Any, @@ -9,7 +10,11 @@ from typing import ( final, overload, ) -from typing_extensions import ParamSpec + +if sys.version_info >= (3, 10): + from typing import ParamSpec +else: + from typing_extensions import ParamSpec from .._types import SupportsLaxedItems from ._classlookup import ElementBase, ElementClassLookup, FallbackElementClassLookup diff --git a/lxml-stubs/etree/_parser.pyi b/lxml-stubs/etree/_parser.pyi index 6b42aa3..f2f8463 100644 --- a/lxml-stubs/etree/_parser.pyi +++ b/lxml-stubs/etree/_parser.pyi @@ -1,6 +1,16 @@ +import sys from _typeshed import _T from typing import Any, Generic, Iterable, Iterator -from typing_extensions import LiteralString, Self, deprecated + +if sys.version_info >= (3, 11): + from typing import LiteralString, Self +else: + from typing_extensions import LiteralString, Self + +if sys.version_info >= (3, 13): + from typing import deprecated +else: + from typing_extensions import deprecated from .._types import ( SupportsLaxedItems, @@ -84,6 +94,7 @@ class _FeedParser(Generic[_ET_co]): ``` """ ... + @deprecated( "Removed since 5.0; deprecated since v2.0 (2008); renamed to set_element_class_lookup()" ) diff --git a/lxml-stubs/etree/_xmlid.pyi b/lxml-stubs/etree/_xmlid.pyi index 917221f..9348e5d 100644 --- a/lxml-stubs/etree/_xmlid.pyi +++ b/lxml-stubs/etree/_xmlid.pyi @@ -1,5 +1,10 @@ +import sys from typing import Collection, Generic, Iterator, overload -from typing_extensions import Self + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self from .._types import _ET, _AnyStr, _FileReadSource from ._element import _Element, _ElementTree diff --git a/lxml-stubs/etree/_xpath.pyi b/lxml-stubs/etree/_xpath.pyi index b156517..bf821b2 100644 --- a/lxml-stubs/etree/_xpath.pyi +++ b/lxml-stubs/etree/_xpath.pyi @@ -3,9 +3,14 @@ # etree/_extension.pxi are merged here. # +import sys from abc import abstractmethod from typing import Any, Callable, Generic, Mapping, Protocol, final, overload -from typing_extensions import deprecated + +if sys.version_info >= (3, 13): + from typing import deprecated +else: + from typing_extensions import deprecated from .._types import ( _ET, diff --git a/lxml-stubs/etree/_xslt.pyi b/lxml-stubs/etree/_xslt.pyi index 71f5ef0..22bfda9 100644 --- a/lxml-stubs/etree/_xslt.pyi +++ b/lxml-stubs/etree/_xslt.pyi @@ -3,8 +3,18 @@ # import abc -from typing import Any, ClassVar, Literal, final, overload -from typing_extensions import TypeAlias, TypedDict, deprecated +import sys +from typing import Any, ClassVar, Literal, TypedDict, final, overload + +if sys.version_info >= (3, 10): + from typing import TypeAlias +else: + from typing_extensions import TypeAlias + +if sys.version_info >= (3, 13): + from typing import deprecated +else: + from typing_extensions import deprecated from .._types import SupportsLaxedItems, _AnyStr, _ElementOrTree, _FileWriteSource from ._classlookup import PIBase @@ -46,6 +56,7 @@ class _XSLTResultTree(_ElementTree[_Element]): As opposed to the generic ``.write()`` method, ``.write_output()`` serialises the result as defined by the ```` tag. """ + @property def xslt_profile(self) -> _ElementTree[_Element] | None: """Return an ElementTree with profiling data for the stylesheet run""" @@ -128,8 +139,9 @@ class XSLT: def __init__( self, xslt_input: _ElementOrTree, - extensions: SupportsLaxedItems[tuple[_AnyStr, _AnyStr], XSLTExtension] - | None = ..., + extensions: ( + SupportsLaxedItems[tuple[_AnyStr, _AnyStr], XSLTExtension] | None + ) = ..., regexp: bool = ..., access_control: XSLTAccessControl | None = ..., ) -> None: ... @@ -197,6 +209,7 @@ class XSLTExtension(metaclass=abc.ABCMeta): is no parent element in the current context (e.g. no content was added to the output tree yet). """ + @overload def apply_templates( self, @@ -247,6 +260,7 @@ class XSLTExtension(metaclass=abc.ABCMeta): Note that the string discarding options will be ignored in this case. """ + @overload def process_children( self, diff --git a/lxml-stubs/html/__init__.pyi b/lxml-stubs/html/__init__.pyi index 57c2c23..7b1d8d8 100644 --- a/lxml-stubs/html/__init__.pyi +++ b/lxml-stubs/html/__init__.pyi @@ -1,4 +1,9 @@ -from typing_extensions import LiteralString +import sys + +if sys.version_info >= (3, 11): + from typing import LiteralString +else: + from typing_extensions import LiteralString from ._element import ( Classes as Classes, diff --git a/lxml-stubs/html/_element.pyi b/lxml-stubs/html/_element.pyi index 5f78da8..81d79b7 100644 --- a/lxml-stubs/html/_element.pyi +++ b/lxml-stubs/html/_element.pyi @@ -1,6 +1,11 @@ +import sys from _typeshed import _T from typing import Callable, Iterable, Iterator, Literal, MutableSet, overload -from typing_extensions import Self + +if sys.version_info >= (3, 11): + from typing import Self +else: + from typing_extensions import Self from .. import etree from .._types import ( diff --git a/lxml-stubs/html/_form.pyi b/lxml-stubs/html/_form.pyi index 58b7d1b..db51e4d 100644 --- a/lxml-stubs/html/_form.pyi +++ b/lxml-stubs/html/_form.pyi @@ -1,3 +1,4 @@ +import sys from typing import ( Any, Callable, @@ -7,7 +8,16 @@ from typing import ( MutableMapping, MutableSet, ) -from typing_extensions import Never, TypeAlias + +if sys.version_info >= (3, 10): + from typing import TypeAlias +else: + from typing_extensions import TypeAlias + +if sys.version_info >= (3, 11): + from typing import Never +else: + from typing_extensions import Never from .._types import SupportsLaxedItems, _AnyStr from ._element import HtmlElement diff --git a/lxml-stubs/html/_funcs.pyi b/lxml-stubs/html/_funcs.pyi index 9b202b2..ce6c389 100644 --- a/lxml-stubs/html/_funcs.pyi +++ b/lxml-stubs/html/_funcs.pyi @@ -1,12 +1,17 @@ +import sys from typing import AnyStr, Callable, Iterator, Literal, TypeVar, overload -from typing_extensions import TypeAlias -from .. import etree +if sys.version_info >= (3, 10): + from typing import TypeAlias +else: + from typing_extensions import TypeAlias + from .._types import _AnyStr, _OutputMethodArg +from ..etree import _ElementTree from ._element import _HANDLE_FAILURES, HtmlElement _HtmlDoc_T = TypeVar("_HtmlDoc_T", str, bytes, HtmlElement) -_HtmlElemOrTree: TypeAlias = HtmlElement | etree._ElementTree[HtmlElement] +_HtmlElemOrTree: TypeAlias = HtmlElement | _ElementTree[HtmlElement] # These are HtmlMixin methods converted to standard functions, # with element or HTML string as first argument followed by all diff --git a/lxml-stubs/html/_parse.pyi b/lxml-stubs/html/_parse.pyi index a785394..8487325 100644 --- a/lxml-stubs/html/_parse.pyi +++ b/lxml-stubs/html/_parse.pyi @@ -1,5 +1,10 @@ +import sys from typing import Any, Iterable, MutableMapping -from typing_extensions import TypeAlias + +if sys.version_info >= (3, 10): + from typing import TypeAlias +else: + from typing_extensions import TypeAlias from .. import etree from .._types import Unused, _AnyStr, _ElemClsLookupArg, _FileReadSource diff --git a/lxml-stubs/html/clean.pyi b/lxml-stubs/html/clean.pyi index 37199b4..7843ea1 100644 --- a/lxml-stubs/html/clean.pyi +++ b/lxml-stubs/html/clean.pyi @@ -1,5 +1,10 @@ +import sys from typing import Iterable, Pattern, TypeVar, Union, overload -from typing_extensions import TypeAlias + +if sys.version_info >= (3, 10): + from typing import TypeAlias +else: + from typing_extensions import TypeAlias from .._types import Unused, _ElemFactory from ..etree import _Element, _ElementTree diff --git a/lxml-stubs/isoschematron.pyi b/lxml-stubs/isoschematron.pyi index c7a8101..78c8424 100644 --- a/lxml-stubs/isoschematron.pyi +++ b/lxml-stubs/isoschematron.pyi @@ -1,5 +1,10 @@ +import sys from typing import Any, ClassVar, overload -from typing_extensions import LiteralString + +if sys.version_info >= (3, 11): + from typing import LiteralString +else: + from typing_extensions import LiteralString from . import etree as _e from ._types import _ElementOrTree, _FileReadSource diff --git a/lxml-stubs/objectify/__init__.pyi b/lxml-stubs/objectify/__init__.pyi index 22acde8..a98fa19 100644 --- a/lxml-stubs/objectify/__init__.pyi +++ b/lxml-stubs/objectify/__init__.pyi @@ -1,4 +1,9 @@ -from typing_extensions import LiteralString +import sys + +if sys.version_info >= (3, 11): + from typing import LiteralString +else: + from typing_extensions import LiteralString from ._annotate import ( PyType as PyType, diff --git a/lxml-stubs/objectify/_element.pyi b/lxml-stubs/objectify/_element.pyi index 365daf5..da3a88b 100644 --- a/lxml-stubs/objectify/_element.pyi +++ b/lxml-stubs/objectify/_element.pyi @@ -3,13 +3,19 @@ # import abc +import sys from typing import Any, Callable, Iterable, Iterator, Literal, overload -from typing_extensions import LiteralString, Self, SupportsIndex +from typing_extensions import SupportsIndex + +if sys.version_info >= (3, 11): + from typing import LiteralString, Self +else: + from typing_extensions import LiteralString, Self -from .. import etree from .._types import _AnyStr, _TagName +from ..etree import CDATA, ElementBase -class ObjectifiedElement(etree.ElementBase): +class ObjectifiedElement(ElementBase): """Main XML Element class Original Docstring @@ -75,7 +81,7 @@ class ObjectifiedDataElement(ObjectifiedElement): @property @abc.abstractmethod def pyval(self) -> Any: ... - def _setText(self, s: _AnyStr | etree.CDATA | None) -> None: + def _setText(self, s: _AnyStr | CDATA | None) -> None: """Modify text content of objectified element directly. Original Docstring @@ -83,6 +89,7 @@ class ObjectifiedDataElement(ObjectifiedElement): For use in subclasses only. Don't use unless you know what you are doing. """ + def _setValueParser(self, function: Callable[[Any], Any]) -> None: """Set the function that parses the Python value from a string