From 857631d3dc3c093b802067bc8821b1a33ef73920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Krassowski?= <5832902+krassowski@users.noreply.github.com> Date: Mon, 20 Feb 2023 19:44:46 +0000 Subject: [PATCH] Do not import pyppeteer for installation check (#1947)Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Matthias Bussonnier * Do not import pyppeteer for installation check * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Fix lint * more details ignore type --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Matthias Bussonnier --- nbconvert/exporters/webpdf.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/nbconvert/exporters/webpdf.py b/nbconvert/exporters/webpdf.py index 183deeb0e..2d15b2b48 100644 --- a/nbconvert/exporters/webpdf.py +++ b/nbconvert/exporters/webpdf.py @@ -7,17 +7,13 @@ import concurrent.futures import os import tempfile +from importlib import util as importlib_util from traitlets import Bool, default from .html import HTMLExporter -try: - import pyppeteer # type:ignore # noqa - - PYPPETEER_INSTALLED = True -except ImportError: - PYPPETEER_INSTALLED = False +PYPPETEER_INSTALLED = importlib_util.find_spec("pyppeteer") is not None class WebPDFExporter(HTMLExporter): @@ -71,7 +67,7 @@ def _template_name_default(self): def _check_launch_reqs(self): try: - from pyppeteer import launch + from pyppeteer import launch # type: ignore[import] from pyppeteer.util import check_chromium # type:ignore except ModuleNotFoundError as e: msg = (