From f848e6b7f2e1adc24340c650e0bbc1c1335c716c Mon Sep 17 00:00:00 2001 From: Karim shoair Date: Mon, 15 Sep 2025 00:19:19 +0300 Subject: [PATCH] fix: Fixes to handle the new extra deps group --- scrapling/cli.py | 6 +++--- scrapling/core/ai.py | 2 +- scrapling/engines/static.py | 8 ++------ scrapling/engines/toolbelt/__init__.py | 12 +----------- scrapling/engines/toolbelt/custom.py | 1 - scrapling/fetchers.py | 2 +- 6 files changed, 8 insertions(+), 23 deletions(-) diff --git a/scrapling/cli.py b/scrapling/cli.py index 0b68721..48e99bf 100644 --- a/scrapling/cli.py +++ b/scrapling/cli.py @@ -10,10 +10,10 @@ from orjson import loads as json_loads, JSONDecodeError try: from click import command, option, Choice, group, argument -except ImportError: - raise ImportError( +except (ImportError, ModuleNotFoundError) as e: + raise ModuleNotFoundError( "You need to install scrapling with any of the extras to enable Shell commands. See: https://scrapling.readthedocs.io/en/latest/#installation" - ) + ) from e __OUTPUT_FILE_HELP__ = "The output file path can be an HTML file, a Markdown file of the HTML content, or the text content itself. Use file extensions (`.html`/`.md`/`.txt`) respectively." __PACKAGE_DIR__ = Path(__file__).parent diff --git a/scrapling/core/ai.py b/scrapling/core/ai.py index 7777c21..ae517fa 100644 --- a/scrapling/core/ai.py +++ b/scrapling/core/ai.py @@ -4,7 +4,7 @@ from mcp.server.fastmcp import FastMCP from pydantic import BaseModel, Field from scrapling.core.shell import Convertor -from scrapling.engines.toolbelt import Response as _ScraplingResponse +from scrapling.engines.toolbelt.custom import Response as _ScraplingResponse from scrapling.fetchers import ( Fetcher, FetcherSession, diff --git a/scrapling/engines/static.py b/scrapling/engines/static.py index 35271b8..3f6cb79 100644 --- a/scrapling/engines/static.py +++ b/scrapling/engines/static.py @@ -24,13 +24,9 @@ from scrapling.core._types import ( Any, ) -from .toolbelt import ( - Response, - generate_headers, - __default_useragent__, -) +from .toolbelt.custom import Response from .toolbelt.convertor import ResponseFactory -from .toolbelt.fingerprints import generate_convincing_referer +from .toolbelt.fingerprints import generate_convincing_referer, generate_headers, __default_useragent__ _UNSET = object() diff --git a/scrapling/engines/toolbelt/__init__.py b/scrapling/engines/toolbelt/__init__.py index 04f43b1..8b13789 100644 --- a/scrapling/engines/toolbelt/__init__.py +++ b/scrapling/engines/toolbelt/__init__.py @@ -1,11 +1 @@ -from .custom import ( - BaseFetcher, - Response, - StatusText, - get_variable_name, -) -from .fingerprints import ( - generate_headers, - get_os_name, - __default_useragent__, -) + diff --git a/scrapling/engines/toolbelt/custom.py b/scrapling/engines/toolbelt/custom.py index 4c4c5e7..774eec7 100644 --- a/scrapling/engines/toolbelt/custom.py +++ b/scrapling/engines/toolbelt/custom.py @@ -3,7 +3,6 @@ Functions related to custom types or type checking """ from functools import lru_cache -from email.message import Message from scrapling.core.utils import log from scrapling.core._types import ( diff --git a/scrapling/fetchers.py b/scrapling/fetchers.py index 323293d..fbb2b28 100644 --- a/scrapling/fetchers.py +++ b/scrapling/fetchers.py @@ -17,7 +17,7 @@ from scrapling.engines._browsers import ( AsyncDynamicSession, AsyncStealthySession, ) -from scrapling.engines.toolbelt import BaseFetcher, Response +from scrapling.engines.toolbelt.custom import BaseFetcher, Response __FetcherClientInstance__ = _FetcherClient() __AsyncFetcherClientInstance__ = _AsyncFetcherClient()