From 453a9e993364fc149776431d151a43668f117a28 Mon Sep 17 00:00:00 2001 From: Lumir Balhar Date: Tue, 8 Oct 2024 14:02:57 +0200 Subject: [PATCH] fixup! Raise warning for unstable URL parsing --- lxml_html_clean/__init__.pyi | 4 +++- lxml_html_clean/clean.pyi | 11 +++++++++++ tests/test_clean.py | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lxml_html_clean/__init__.pyi b/lxml_html_clean/__init__.pyi index f42a110..07e344b 100644 --- a/lxml_html_clean/__init__.pyi +++ b/lxml_html_clean/__init__.pyi @@ -5,5 +5,7 @@ from .clean import ( autolink as autolink, autolink_html as autolink_html, word_break as word_break, - word_break_html as word_break_html + word_break_html as word_break_html, + LXMLHTMLCleanWarning as LXMLHTMLCleanWarning, + AmbiguousURLWarning as AmbiguousURLWarning, ) diff --git a/lxml_html_clean/clean.pyi b/lxml_html_clean/clean.pyi index 4547afa..c05b7b9 100644 --- a/lxml_html_clean/clean.pyi +++ b/lxml_html_clean/clean.pyi @@ -8,6 +8,17 @@ _DT = TypeVar("_DT", str, bytes, HtmlElement) _ET_DT = TypeVar("_ET_DT", str, bytes, HtmlElement, _ElementTree[HtmlElement]) +def _get_authority_from_url(url: str) -> str | bool: ... + + +class LXMLHTMLCleanWarning(Warning): + pass + + +class AmbiguousURLWarning(LXMLHTMLCleanWarning): + pass + + class Cleaner: @overload # allow_tags present, remove_unknown_tags must be False def __init__( diff --git a/tests/test_clean.py b/tests/test_clean.py index 2fe733b..85692a1 100644 --- a/tests/test_clean.py +++ b/tests/test_clean.py @@ -5,7 +5,7 @@ import warnings import lxml.html -from lxml_html_clean import AmbiguousURLWarning, Cleaner, clean_html, LXMLHTMLCleanWarning # type:ignore +from lxml_html_clean import AmbiguousURLWarning, Cleaner, clean_html, LXMLHTMLCleanWarning from .utils import peak_memory_usage