From 3a01ff0ebe57071f032d903a43b1b57662cd9af9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 10:48:54 +0000 Subject: [PATCH 1/2] Bump lxml-stubs from 0.4.0 to 0.5.1 Bumps [lxml-stubs](https://github.com/lxml/lxml-stubs) from 0.4.0 to 0.5.1. - [Release notes](https://github.com/lxml/lxml-stubs/releases) - [Commits](https://github.com/lxml/lxml-stubs/compare/0.4.0...0.5.1) --- updated-dependencies: - dependency-name: lxml-stubs dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- poetry.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index 55d53cc1e37..f4948d3db8a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1212,17 +1212,17 @@ source = ["Cython (>=3.0.7)"] [[package]] name = "lxml-stubs" -version = "0.4.0" +version = "0.5.1" description = "Type annotations for the lxml package" optional = false python-versions = "*" files = [ - {file = "lxml-stubs-0.4.0.tar.gz", hash = "sha256:184877b42127256abc2b932ba8bd0ab5ea80bd0b0fee618d16daa40e0b71abee"}, - {file = "lxml_stubs-0.4.0-py3-none-any.whl", hash = "sha256:3b381e9e82397c64ea3cc4d6f79d1255d015f7b114806d4826218805c10ec003"}, + {file = "lxml-stubs-0.5.1.tar.gz", hash = "sha256:e0ec2aa1ce92d91278b719091ce4515c12adc1d564359dfaf81efa7d4feab79d"}, + {file = "lxml_stubs-0.5.1-py3-none-any.whl", hash = "sha256:1f689e5dbc4b9247cb09ae820c7d34daeb1fdbd1db06123814b856dae7787272"}, ] [package.extras] -test = ["coverage[toml] (==5.2)", "pytest (>=6.0.0)", "pytest-mypy-plugins (==1.9.3)"] +test = ["coverage[toml] (>=7.2.5)", "mypy (>=1.2.0)", "pytest (>=7.3.0)", "pytest-mypy-plugins (>=1.10.1)"] [[package]] name = "markdown-it-py" From 4cf2270d20a6a18709ae248ea6cbdd2de0bf9404 Mon Sep 17 00:00:00 2001 From: Erik Johnston Date: Tue, 6 Feb 2024 09:19:55 +0000 Subject: [PATCH 2/2] Fix up --- synapse/media/oembed.py | 5 ++--- synapse/media/preview_html.py | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/synapse/media/oembed.py b/synapse/media/oembed.py index 94ece304599..16d613d271c 100644 --- a/synapse/media/oembed.py +++ b/synapse/media/oembed.py @@ -256,12 +256,11 @@ def calc_description_and_urls(open_graph_response: JsonDict, html_body: str) -> parser = etree.HTMLParser(recover=True, encoding="utf-8") # Attempt to parse the body. If this fails, log and return no metadata. - # TODO Develop of lxml-stubs has this correct. - tree = etree.fromstring(html_body, parser) # type: ignore[arg-type] + tree = etree.fromstring(html_body, parser) # The data was successfully parsed, but no tree was found. if tree is None: - return # type: ignore[unreachable] + return # Attempt to find interesting URLs (images, videos, embeds). if "og:image" not in open_graph_response: diff --git a/synapse/media/preview_html.py b/synapse/media/preview_html.py index 8a2c098d530..62ce7789bed 100644 --- a/synapse/media/preview_html.py +++ b/synapse/media/preview_html.py @@ -160,8 +160,7 @@ def decode_body( # Attempt to parse the body. Returns None if the body was successfully # parsed, but no tree was found. - # TODO Develop of lxml-stubs has this correct. - return etree.fromstring(body, parser) # type: ignore[arg-type] + return etree.fromstring(body, parser) def _get_meta_tags(