Karim shoair commited on
Commit ·
916aa58
1
Parent(s): ae7cbae
fix: use the correct signature for the `stealthy_fetch` shortcut
Browse files- scrapling/core/shell.py +5 -5
scrapling/core/shell.py
CHANGED
|
@@ -314,7 +314,7 @@ class CurlParser:
|
|
| 314 |
return None
|
| 315 |
|
| 316 |
|
| 317 |
-
def _unpack_signature(func):
|
| 318 |
"""
|
| 319 |
Unpack TypedDict from Unpack[TypedDict] annotations in **kwargs and reconstruct the signature.
|
| 320 |
|
|
@@ -322,7 +322,7 @@ def _unpack_signature(func):
|
|
| 322 |
"""
|
| 323 |
try:
|
| 324 |
sig = signature(func)
|
| 325 |
-
func_name = getattr(func, "__name__", None)
|
| 326 |
|
| 327 |
# Check if this function has known parameters
|
| 328 |
if func_name not in Signatures_map:
|
|
@@ -467,7 +467,7 @@ Type 'exit' or press Ctrl+D to exit.
|
|
| 467 |
|
| 468 |
return result
|
| 469 |
|
| 470 |
-
def create_wrapper(self, func, get_signature=True):
|
| 471 |
"""Create a wrapper that preserves function signature but updates page"""
|
| 472 |
|
| 473 |
@wraps(func)
|
|
@@ -477,7 +477,7 @@ Type 'exit' or press Ctrl+D to exit.
|
|
| 477 |
|
| 478 |
if get_signature:
|
| 479 |
# Explicitly preserve and unpack signature for IPython introspection and autocompletion
|
| 480 |
-
wrapper.__signature__ = _unpack_signature(func) # pyright: ignore
|
| 481 |
else:
|
| 482 |
wrapper.__signature__ = signature(func) # pyright: ignore
|
| 483 |
|
|
@@ -492,7 +492,7 @@ Type 'exit' or press Ctrl+D to exit.
|
|
| 492 |
put = self.create_wrapper(self.__Fetcher.put)
|
| 493 |
delete = self.create_wrapper(self.__Fetcher.delete)
|
| 494 |
dynamic_fetch = self.create_wrapper(self.__DynamicFetcher.fetch)
|
| 495 |
-
stealthy_fetch = self.create_wrapper(self.__StealthyFetcher.fetch)
|
| 496 |
curl2fetcher = self.create_wrapper(self._curl_parser.convert2fetcher, get_signature=False)
|
| 497 |
|
| 498 |
# Create the namespace dictionary
|
|
|
|
| 314 |
return None
|
| 315 |
|
| 316 |
|
| 317 |
+
def _unpack_signature(func, signature_name=None):
|
| 318 |
"""
|
| 319 |
Unpack TypedDict from Unpack[TypedDict] annotations in **kwargs and reconstruct the signature.
|
| 320 |
|
|
|
|
| 322 |
"""
|
| 323 |
try:
|
| 324 |
sig = signature(func)
|
| 325 |
+
func_name = signature_name or getattr(func, "__name__", None)
|
| 326 |
|
| 327 |
# Check if this function has known parameters
|
| 328 |
if func_name not in Signatures_map:
|
|
|
|
| 467 |
|
| 468 |
return result
|
| 469 |
|
| 470 |
+
def create_wrapper(self, func, get_signature=True, signature_name=None):
|
| 471 |
"""Create a wrapper that preserves function signature but updates page"""
|
| 472 |
|
| 473 |
@wraps(func)
|
|
|
|
| 477 |
|
| 478 |
if get_signature:
|
| 479 |
# Explicitly preserve and unpack signature for IPython introspection and autocompletion
|
| 480 |
+
wrapper.__signature__ = _unpack_signature(func, signature_name) # pyright: ignore
|
| 481 |
else:
|
| 482 |
wrapper.__signature__ = signature(func) # pyright: ignore
|
| 483 |
|
|
|
|
| 492 |
put = self.create_wrapper(self.__Fetcher.put)
|
| 493 |
delete = self.create_wrapper(self.__Fetcher.delete)
|
| 494 |
dynamic_fetch = self.create_wrapper(self.__DynamicFetcher.fetch)
|
| 495 |
+
stealthy_fetch = self.create_wrapper(self.__StealthyFetcher.fetch, signature_name="stealthy_fetch")
|
| 496 |
curl2fetcher = self.create_wrapper(self._curl_parser.convert2fetcher, get_signature=False)
|
| 497 |
|
| 498 |
# Create the namespace dictionary
|