Skip to content

Commit c8731eb

Browse files
fix: resolve ruff linting errors and type annotation issue
1 parent fc5999a commit c8731eb

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

pydoll/browser/interfaces.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
from abc import ABC, abstractmethod
22

3-
from pydoll.constants import PageLoadState
4-
53
from pydoll.browser.preference_types import BrowserPreferences
4+
from pydoll.constants import PageLoadState
65

76

87
class Options(ABC):

pydoll/browser/managers/temp_dir_manager.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,11 @@ def handle_cleanup_error(self, func: Callable[[str], None], path: str, exc_info:
7979
Note:
8080
Handles Chromium-specific locked files like CrashpadMetrics.
8181
"""
82-
matches = ['CrashpadMetrics-active.pma']
82+
matches = ['CrashpadMetrics-active.pma', 'Cookies', 'Network']
8383
exc_type, exc_value, _ = exc_info
8484

8585
if exc_type is PermissionError:
86-
if Path(path).name in matches:
86+
if Path(path).name in matches or 'Network' in str(Path(path)):
8787
try:
8888
self.retry_process_file(func, path)
8989
return

pydoll/browser/options.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self):
3131
self._arguments: list[str] = []
3232
self._binary_location: str = ''
3333
self._start_timeout: int = 10
34-
self._browser_preferences: BrowserPreferences = {}
34+
self._browser_preferences: dict[str, Any] = {}
3535
self._headless: bool = False
3636
self._page_load_state: PageLoadState = PageLoadState.COMPLETE
3737

@@ -126,7 +126,7 @@ def remove_argument(self, argument: str):
126126

127127
@property
128128
def browser_preferences(self) -> BrowserPreferences:
129-
return self._browser_preferences
129+
return cast(BrowserPreferences, self._browser_preferences)
130130

131131
@browser_preferences.setter
132132
def browser_preferences(self, preferences: BrowserPreferences):
@@ -191,20 +191,22 @@ def _validate_pref_value(path: list[str], value: Any) -> None:
191191
# Expected is a subschema dict; value must be a dict and match the schema
192192
if not isinstance(value, dict):
193193
raise InvalidPreferenceValue(
194-
f'Invalid value type for {".".join(path)}: expected dict, got {type(value).__name__}'
194+
f'Invalid value type for {".".join(path)}: '
195+
f'expected dict, got {type(value).__name__}'
195196
)
196197
# Recursively validate each key-value in the value dict
197198
for k, v in value.items():
198199
if k not in expected:
199-
raise InvalidPreferencePath(f'Invalid key "{k}" in preference path {".".join(path)}')
200-
sub_expected = expected[k]
200+
raise InvalidPreferencePath(
201+
f'Invalid key "{k}" in preference path {".".join(path)}'
202+
)
201203
ChromiumOptions._validate_pref_value(path + [k], v)
202-
else:
204+
elif not isinstance(value, expected):
203205
# Expected is a primitive type; check isinstance
204-
if not isinstance(value, expected):
205-
raise InvalidPreferenceValue(
206-
f'Invalid value type for {".".join(path)}: expected {expected.__name__}, got {type(value).__name__}'
207-
)
206+
raise InvalidPreferenceValue(
207+
f'Invalid value type for {".".join(path)}: '
208+
f'expected {expected.__name__}, got {type(value).__name__}'
209+
)
208210

209211
def _get_pref_path(self, path: list):
210212
"""

pydoll/browser/preference_types.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import TypedDict, Any
1+
from typing import TypedDict
2+
23
from typing_extensions import NotRequired
34

45

0 commit comments

Comments
 (0)