39
40def _import_bs4(
41▶ *, import_error_message: str
42) -> tuple[type[BeautifulSoup], type[Tag], type[NavigableString]]:
43 try:
· · ·
44 from bs4 import BeautifulSoup, Tag # noqa: PLC0415
45 from bs4.element import NavigableString # noqa: PLC0415
46▶ except ImportError as err:
47 raise ImportError(import_error_message) from err
48 return BeautifulSoup, Tag, NavigableString
· · ·
47▶ raise ImportError(import_error_message) from err
48 return BeautifulSoup, Tag, NavigableString
49
· · ·
52 try:
53 from lxml import etree # noqa: PLC0415
54▶ except ImportError as err:
55 msg = "Unable to import lxml, please install with `pip install lxml`."
56 raise ImportError(msg) from err
· · ·
56▶ raise ImportError(msg) from err
57 return etree
58
+ 15 more matches in this file