Skip to content

Commit c789c8f

Browse files
committed
update
1 parent 171311a commit c789c8f

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

pyproject.toml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
[project]
22
name = "wrighter"
3-
version = "0.1.2"
4-
description = "eb scraping/browser automation framework built on Playwright"
3+
version = "0.1.3"
4+
description = "Web scraping/browser automation framework built on Playwright"
55
authors = [{ name = "Žiga Ivanšek", email = "[email protected]" }]
66
license = { file = "LICENSE.txt" }
77
readme = "README.md"
88
requires-python = ">=3.10"
99

1010
dependencies = [
11-
"playwright>=1.33.0",
12-
"pydantic>=1.10.8",
13-
"playwright_stealth>=1.0.5",
14-
"stdl>=0.5.5",
11+
"playwright>=1.50.0",
12+
"pydantic>=2.10.6",
13+
"playwright-stealth @ git+https://github.com/Mattwmaster58/playwright_stealth@rc4",
14+
"stdl>=0.6.1",
1515
"loguru>=0.7.0",
1616
]
1717

wrighter/options.py

+13-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import json
21
import os
32
from pathlib import Path
43
from typing import Any, Literal, Mapping
@@ -11,7 +10,7 @@
1110
StorageState,
1211
ViewportSize,
1312
)
14-
from pydantic import BaseModel, validator
13+
from pydantic import BaseModel, field_validator
1514
from stdl import fs
1615
from stdl.st import FG, colored
1716

@@ -143,31 +142,34 @@ def persistent_context_options(self) -> dict[str, Any]:
143142
opts["user_data_dir"] = self.user_data_dir
144143
return opts
145144

146-
@validator("browser")
147-
def __validate_browser(cls, v: str):
145+
@field_validator("browser")
146+
@classmethod
147+
def validate_browser(cls, v: str) -> str:
148148
v = v.lower().strip()
149149
if v == "chrome":
150150
v = "chromium"
151151
if v not in BROWSERS:
152152
raise ValueError(f"Possible values for 'browser' are {BROWSERS}")
153153
return v
154154

155-
@validator("permissions", each_item=True)
156-
def __validate_permissions(cls, v):
155+
@field_validator("permissions", mode="before")
156+
@classmethod
157+
def validate_permissions(cls, v: T.Any) -> T.Any:
157158
if isinstance(v, str):
158159
v = v.lower()
159160
if v not in PERMISSIONS:
160161
raise ValueError(v)
161162
return v
162163

163-
@validator("viewport", "screen", "record_video_size")
164-
def __validate_viewport_size(cls, v: ViewportSize):
164+
@field_validator("viewport", "screen", "record_video_size")
165+
@classmethod
166+
def validate_viewport_size(cls, v: dict[str, int]) -> dict[str, int]:
165167
MIN_VIEWPORT_SIZE = 100
166168
if v["width"] < MIN_VIEWPORT_SIZE or v["height"] < MIN_VIEWPORT_SIZE:
167169
raise ValueError(v)
168170
return v
169171

170-
@validator(
172+
@field_validator(
171173
"user_data_dir",
172174
"data_dir",
173175
"executable_path",
@@ -177,7 +179,8 @@ def __validate_viewport_size(cls, v: ViewportSize):
177179
"record_video_dir",
178180
"storage_state",
179181
)
180-
def __validate_path(cls, v):
182+
@classmethod
183+
def validate_path(cls, v: Path) -> str:
181184
fs.ensure_paths_exist(v)
182185
return os.path.abspath(str(v))
183186

wrighter/plugin_manager.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ def add_plugin(self, plugin: Plugin, *, existing=True):
1515
1616
Args:
1717
plugin (Plugin): The plugin to add.
18-
existing (bool, optional): If `True`, adds the plugin to all existing pages and contexts.
19-
Defaults to `True`.
18+
existing (bool, optional): If `True`, adds the plugin to all existing pages and contexts. Defaults to `True`.
2019
2120
Returns:
2221
None
@@ -34,8 +33,7 @@ def remove_plugin(self, plugin: Plugin, *, existing=True) -> None:
3433
3534
Args:
3635
plugin (Plugin): The plugin to remove.
37-
existing (bool, optional): If `True`, remove the plugin from all existing pages and contexts.
38-
Defaults to `True`.
36+
existing (bool, optional): If `True`, remove the plugin from all existing pages and contexts. Defaults to `True`.
3937
4038
Returns:
4139
None
@@ -52,8 +50,7 @@ def remove_all(self, *, existing=True) -> None:
5250
Remove all plugin from the current instance.
5351
5452
Args:
55-
existing (bool, optional): If `True`, alose remove all the plugin all from existing pages and contexts.
56-
Defaults to `True`.
53+
existing (bool, optional): If `True`, alose remove all the plugin all from existing pages and contexts. Defaults to `True`.
5754
5855
Returns:
5956
None

0 commit comments

Comments
 (0)