44
55import sys
66from abc import ABCMeta , abstractmethod
7- from typing import Final , overload
7+ from typing import Any , Final , Literal , overload
88
99from .._types import (
1010 _ElementOrTree ,
@@ -20,6 +20,11 @@ if sys.version_info >= (3, 11):
2020else :
2121 from typing_extensions import LiteralString
2222
23+ if sys .version_info >= (3 , 13 ):
24+ from warnings import deprecated
25+ else :
26+ from typing_extensions import deprecated
27+
2328DEBUG : int
2429ICONV_COMPILED_VERSION : Final [tuple [int , int ]]
2530LIBXML_COMPILED_VERSION : Final [tuple [int , int , int ]]
@@ -91,40 +96,36 @@ class DocInfo:
9196class QName :
9297 """QName wrapper for qualified XML names.
9398
94- Pass a tag name by itself or a namespace URI and a tag name to
95- create a qualified name. Alternatively, pass an Element to
96- extract its tag name. ``None`` as first argument is ignored in
97- order to allow for generic 2-argument usage.
98-
99- The ``text`` property holds the qualified name in
100- ``{namespace}tagname`` notation. The ``.namespace`` and
101- ``.localname`` properties hold the respective parts of the tag
102- name.
103-
104- You can pass QName objects wherever a tag name is expected. Also,
105- setting Element text from a QName will resolve the namespace prefix
106- on assignment and set a qualified text value. This is helpful in XML
107- languages like SOAP or XML-Schema that use prefixed tag names in
108- their text content.
99+ See Also
100+ --------
101+ - [API Documentation](https://lxml.de/apidoc/lxml.etree.html#lxml.etree.QName)
109102 """
110- @overload
103+ @overload # empty string = exception
104+ @deprecated ("Use None instead, empty string would cause exception" )
105+ def __init__ (
106+ self ,
107+ text_or_uri_or_element : Literal ["" ],
108+ tag : Any = None ,
109+ ) -> None : ... # Switching to Never causes testsuite problem
110+ @overload # first arg non-empty
111111 def __init__ (
112112 self ,
113- text_or_uri_or_element : _TagName | _Element ,
114- tag : _TagName | None = None ,
113+ text_or_uri_or_element : str | bytes | QName | _Element ,
114+ tag : _TextArg | None = None ,
115115 ) -> None : ...
116- @overload
116+ @overload # first arg empty
117117 def __init__ (
118118 self ,
119119 text_or_uri_or_element : None ,
120- tag : _TagName | _Element ,
120+ tag : str | bytes | QName | _Element ,
121121 ) -> None : ...
122122 @property
123123 def localname (self ) -> str : ...
124124 @property
125125 def namespace (self ) -> str | None : ...
126126 @property
127- def text (self ) -> str : ...
127+ def text (self ) -> str :
128+ """Holds the qualified name in `{namespace}tagname` notation"""
128129 # Emulate __richcmp__()
129130 def __ge__ (self , other : _TagName ) -> bool : ...
130131 def __gt__ (self , other : _TagName ) -> bool : ...
0 commit comments