Using the new types file

This commit is contained in:
Karim shoair
2024-10-31 01:32:18 +03:00
parent 1ca2b6cfe4
commit 23c4181ff2
4 changed files with 4 additions and 19 deletions
+1 -11
View File
@@ -9,24 +9,14 @@ which will be important in future releases but most importantly...
import re
from w3lib.html import HTML5_WHITESPACE
from typing import TYPE_CHECKING, Any, Optional
try:
from typing import Protocol
except ImportError:
# Added in Python 3.8
Protocol = object
from scrapling.utils import cache
from scrapling._types import Any, Optional, Protocol, Self
from cssselect.xpath import ExpressionError
from cssselect.xpath import XPathExpr as OriginalXPathExpr
from cssselect import HTMLTranslator as OriginalHTMLTranslator
from cssselect.parser import Element, FunctionalPseudoElement, PseudoElement
if TYPE_CHECKING:
# typing.Self requires Python 3.11
from typing_extensions import Self
regex = f"[{HTML5_WHITESPACE}]+"
replace_html5_whitespaces = re.compile(regex).sub