diff --git a/pyproject.toml b/pyproject.toml index ede8406..e412a88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,7 +72,7 @@ lxml49 = ["lxml == 4.9.4"] lxml50 = ["lxml == 5.0.2"] lxml51 = ["lxml == 5.1.1"] lxml52 = ["lxml == 5.2.2"] -lxml53 = ["lxml == 5.3.0"] +lxml53 = ["lxml == 5.3.1"] dev = [ 'tox ~= 4.22', # microsoft/pyright#9286, microsoft/pyright#9296, microsoft/pyright#9412 diff --git a/src/lxml-stubs/etree/__init__.pyi b/src/lxml-stubs/etree/__init__.pyi index 169429c..8f6fc76 100644 --- a/src/lxml-stubs/etree/__init__.pyi +++ b/src/lxml-stubs/etree/__init__.pyi @@ -62,7 +62,9 @@ from ._module_misc import ( CDATA as CDATA, DEBUG as DEBUG, ICONV_COMPILED_VERSION as ICONV_COMPILED_VERSION, + LIBXML_COMPILED_FEATURES as LIBXML_COMPILED_FEATURES, LIBXML_COMPILED_VERSION as LIBXML_COMPILED_VERSION, + LIBXML_FEATURES as LIBXML_FEATURES, LIBXML_VERSION as LIBXML_VERSION, LXML_VERSION as LXML_VERSION, C14NError as C14NError, diff --git a/src/lxml-stubs/etree/_dtd.pyi b/src/lxml-stubs/etree/_dtd.pyi index 84fe8d5..0d70405 100644 --- a/src/lxml-stubs/etree/_dtd.pyi +++ b/src/lxml-stubs/etree/_dtd.pyi @@ -85,7 +85,9 @@ class DTD(_Validator): @overload def __init__(self, file: _FileReadSource) -> None: ... @overload - def __init__(self, file: None = None, *, external_id: bytes) -> None: ... + def __init__( # str only supported since 5.3.1 + self, file: None = None, *, external_id: str | bytes | bytearray + ) -> None: ... @property def name(self) -> str | None: ... @property diff --git a/src/lxml-stubs/etree/_module_func.pyi b/src/lxml-stubs/etree/_module_func.pyi index 39d973d..1a71c8a 100644 --- a/src/lxml-stubs/etree/_module_func.pyi +++ b/src/lxml-stubs/etree/_module_func.pyi @@ -470,6 +470,7 @@ class _MemDebug: The current size of the global name dictionary used by libxml2 for the current thread. Each thread has its own dictionary. """ + @deprecated("Removed since 6.0, due to corresponding removal in libxml2") def dump( self, output_file: str | bytes | None = None, byte_count: int | None = None ) -> None: @@ -482,6 +483,7 @@ class _MemDebug: byte_count : int, optional Limits number of bytes in the dump, default is None (unlimited) """ + @deprecated("Removed since 6.0, due to corresponding removal in libxml2") def show( self, output_file: str | bytes | None = None, block_count: int | None = None ) -> None: diff --git a/src/lxml-stubs/etree/_module_misc.pyi b/src/lxml-stubs/etree/_module_misc.pyi index c1cf368..6f77f5f 100644 --- a/src/lxml-stubs/etree/_module_misc.pyi +++ b/src/lxml-stubs/etree/_module_misc.pyi @@ -24,7 +24,9 @@ from ._xmlerror import _BaseErrorLog, _ListErrorLog DEBUG: int ICONV_COMPILED_VERSION: tuple[int, int] LIBXML_VERSION: tuple[int, int, int] +LIBXML_COMPILED_FEATURES: set[str] LIBXML_COMPILED_VERSION: tuple[int, int, int] +LIBXML_FEATURES: set[str] LXML_VERSION: tuple[int, int, int, int] __version__: LiteralString diff --git a/src/lxml-stubs/html/builder.pyi b/src/lxml-stubs/html/builder.pyi index c8a3739..cf14399 100644 --- a/src/lxml-stubs/html/builder.pyi +++ b/src/lxml-stubs/html/builder.pyi @@ -19,31 +19,44 @@ ACRONYM = E.acronym ADDRESS = E.address APPLET = E.applet AREA = E.area +ARTICLE = E.article +ASIDE = E.aside +AUDIO = E.audio B = E.b BASE = E.base BASEFONT = E.basefont +BDI = E.bdi BDO = E.bdo BIG = E.big BLOCKQUOTE = E.blockquote BODY = E.body BR = E.br BUTTON = E.button +CANVAS = E.canvas CAPTION = E.caption CENTER = E.center CITE = E.cite CODE = E.code COL = E.col COLGROUP = E.colgroup +DATA = E.data +DATALIST = E.datalist DD = E.dd DEL = E.__getattr__("del") +DETAILS = E.details DFN = E.dfn +DIALOG = E.dialog DIR = E.dir DIV = E.div DL = E.dl DT = E.dt EM = E.em +EMBED = E.embed FIELDSET = E.fieldset +FIGCAPTION = E.figcaption +FIGURE = E.figure FONT = E.font +FOOTER = E.footer FORM: partial[FormElement] FRAME = E.frame FRAMESET = E.frameset @@ -54,6 +67,8 @@ H4 = E.h4 H5 = E.h5 H6 = E.h6 HEAD = E.head +HEADER = E.header +HGROUP = E.hgroup HR = E.hr HTML = E.html I = E.i @@ -67,43 +82,68 @@ LABEL: partial[LabelElement] LEGEND = E.legend LI = E.li LINK = E.link +MAIN = E.main MAP = E.map +MARK = E.mark +MARQUEE = E.marquee MENU = E.menu META = E.meta +METER = E.meter +NAV = E.nav +NOBR = E.nobr NOFRAMES = E.noframes NOSCRIPT = E.noscript OBJECT = E.object OL = E.ol OPTGROUP = E.optgroup OPTION = E.option +OUTPUT = E.output P = E.p PARAM = E.param +PICTURE = E.picture +PORTAL = E.portal PRE = E.pre +PROGRESS = E.progress Q = E.q +RB = E.rb +RP = E.rp +RT = E.rt +RTC = E.rtc +RUBY = E.ruby S = E.s SAMP = E.samp SCRIPT = E.script +SEARCH = E.search +SECTION = E.section SELECT: partial[SelectElement] +SLOT = E.slot SMALL = E.small +SOURCE = E.source SPAN = E.span STRIKE = E.strike STRONG = E.strong STYLE = E.style SUB = E.sub +SUMMARY = E.summary SUP = E.sup TABLE = E.table TBODY = E.tbody TD = E.td +TEMPLATE = E.template TEXTAREA: partial[TextareaElement] TFOOT = E.tfoot TH = E.th THEAD = E.thead +TIME = E.time TITLE = E.title TR = E.tr +TRACK = E.track TT = E.tt U = E.u UL = E.ul VAR = E.var +VIDEO = E.video +WBR = E.wbr # attributes ATTR = dict diff --git a/tests/runtime/test_constants.py b/tests/runtime/test_constants.py index 6bc0b59..95ee9db 100644 --- a/tests/runtime/test_constants.py +++ b/tests/runtime/test_constants.py @@ -27,6 +27,10 @@ def test_ver_const(self) -> None: if hasattr(_e, "ICONV_COMPILED_VERSION"): reveal_type(_e.ICONV_COMPILED_VERSION) + if _e.LXML_VERSION >= (6, 0): + reveal_type(_e.LIBXML_COMPILED_FEATURES) + reveal_type(_e.LIBXML_FEATURES) + def test_other_const(self) -> None: reveal_type(_e.DEBUG) _e.DEBUG = 1 diff --git a/tests/static/test-dtd.yml b/tests/static/test-dtd.yml index e53034c..e07274c 100644 --- a/tests/static/test-dtd.yml +++ b/tests/static/test-dtd.yml @@ -8,14 +8,16 @@ - args: filename - args: file=path - args: fileio - - args: external_id=dtd_id + - args: external_id=b + - args: external_id=s main: | from pathlib import PosixPath from lxml.etree import DTD filename: str path: PosixPath fileio = open('file', 'r') - dtd_id: bytes + b: bytes + s: str reveal_type(DTD({{ args }})) # N: Revealed type is "lxml.etree._dtd.DTD" - case: constructor_noargs @@ -24,14 +26,13 @@ from lxml.etree import DTD dtd = DTD() -# str not supported as of lxml 4.8 - case: constructor_badargs expect_fail: true parametrized: - args: 1 - args: "None, 1" - args: "None, badarg=b" - - args: "external_id=s" + - args: "external_id=1" main: | from lxml.etree import DTD s: str