Karim shoair commited on
Commit ·
e67328d
1
Parent(s): 7f8ebce
refactor(validators): Optimize imports
Browse files
scrapling/engines/_browsers/_validators.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
|
| 2 |
from urllib.parse import urlparse
|
| 3 |
|
| 4 |
from scrapling.core._types import (
|
|
@@ -12,7 +12,7 @@ from scrapling.core._types import (
|
|
| 12 |
from scrapling.engines.toolbelt import construct_proxy_dict
|
| 13 |
|
| 14 |
|
| 15 |
-
class PlaywrightConfig(
|
| 16 |
"""Configuration struct for validation"""
|
| 17 |
|
| 18 |
max_pages: int = 1
|
|
@@ -81,8 +81,8 @@ class PlaywrightConfig(msgspec.Struct, kw_only=True, frozen=False):
|
|
| 81 |
|
| 82 |
def validate(params, model):
|
| 83 |
try:
|
| 84 |
-
config =
|
| 85 |
-
except
|
| 86 |
raise TypeError(f"Invalid argument type: {e}")
|
| 87 |
|
| 88 |
return config
|
|
|
|
| 1 |
+
from msgspec import Struct, convert, ValidationError
|
| 2 |
from urllib.parse import urlparse
|
| 3 |
|
| 4 |
from scrapling.core._types import (
|
|
|
|
| 12 |
from scrapling.engines.toolbelt import construct_proxy_dict
|
| 13 |
|
| 14 |
|
| 15 |
+
class PlaywrightConfig(Struct, kw_only=True, frozen=False):
|
| 16 |
"""Configuration struct for validation"""
|
| 17 |
|
| 18 |
max_pages: int = 1
|
|
|
|
| 81 |
|
| 82 |
def validate(params, model):
|
| 83 |
try:
|
| 84 |
+
config = convert(params, model)
|
| 85 |
+
except ValidationError as e:
|
| 86 |
raise TypeError(f"Invalid argument type: {e}")
|
| 87 |
|
| 88 |
return config
|