refactor(validators): Optimize imports
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import msgspec
|
from msgspec import Struct, convert, ValidationError
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from scrapling.core._types import (
|
from scrapling.core._types import (
|
||||||
@@ -12,7 +12,7 @@ from scrapling.core._types import (
|
|||||||
from scrapling.engines.toolbelt import construct_proxy_dict
|
from scrapling.engines.toolbelt import construct_proxy_dict
|
||||||
|
|
||||||
|
|
||||||
class PlaywrightConfig(msgspec.Struct, kw_only=True, frozen=False):
|
class PlaywrightConfig(Struct, kw_only=True, frozen=False):
|
||||||
"""Configuration struct for validation"""
|
"""Configuration struct for validation"""
|
||||||
|
|
||||||
max_pages: int = 1
|
max_pages: int = 1
|
||||||
@@ -81,8 +81,8 @@ class PlaywrightConfig(msgspec.Struct, kw_only=True, frozen=False):
|
|||||||
|
|
||||||
def validate(params, model):
|
def validate(params, model):
|
||||||
try:
|
try:
|
||||||
config = msgspec.convert(params, model)
|
config = convert(params, model)
|
||||||
except msgspec.ValidationError as e:
|
except ValidationError as e:
|
||||||
raise TypeError(f"Invalid argument type: {e}")
|
raise TypeError(f"Invalid argument type: {e}")
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|||||||
Reference in New Issue
Block a user