Skip to content

Commit 2405c57

Browse files
改进检查
1 parent 6cfc3a1 commit 2405c57

File tree

5 files changed

+15
-4
lines changed

5 files changed

+15
-4
lines changed

pydoll/connection/connection_handler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@ def _is_connection_closed(self) -> bool:
200200

201201
def _check_connection_state(self) -> bool:
202202
"""Check connection state using various methods for compatibility."""
203+
# This method is only called when _ws_connection is not None
204+
assert self._ws_connection is not None
205+
203206
# For websockets library (newer versions)
204207
if hasattr(self._ws_connection, 'closed'):
205208
return self._ws_connection.closed
@@ -217,6 +220,7 @@ def _check_connection_state(self) -> bool:
217220

218221
def _check_state_attribute(self) -> bool:
219222
"""Check connection state attribute."""
223+
assert self._ws_connection is not None
220224
state = self._ws_connection.state
221225
if hasattr(state, 'name'):
222226
return state.name in {'CLOSED', 'CLOSING'}

pydoll/fingerprint/browser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ async def _inject_fingerprint_script(self, tab: Tab):
110110
"""
111111
try:
112112
# Get the JavaScript injection code
113+
assert self.fingerprint_manager is not None
113114
script = self.fingerprint_manager.get_fingerprint_js()
114115

115116
# Inject the script using Page.addScriptToEvaluateOnNewDocument
@@ -241,6 +242,7 @@ async def _inject_fingerprint_script(self, tab: Tab):
241242
"""
242243
try:
243244
# Get the JavaScript injection code
245+
assert self.fingerprint_manager is not None
244246
script = self.fingerprint_manager.get_fingerprint_js()
245247

246248
# Inject the script using Page.addScriptToEvaluateOnNewDocument

pydoll/fingerprint/models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def to_dict(self) -> Dict[str, Union[str, int, float, bool, List, None]]:
8383
@classmethod
8484
def from_dict(cls, data: Dict[str, Union[str, int, float, bool, List, None]]) -> 'Fingerprint':
8585
"""Create fingerprint from dictionary format."""
86-
return cls(**data)
86+
return cls(**data) # type: ignore[arg-type]
8787

8888

8989
@dataclass
@@ -135,4 +135,4 @@ def to_dict(self) -> Dict[str, Union[str, int, bool, List, None]]:
135135
@classmethod
136136
def from_dict(cls, data: Dict[str, Union[str, int, bool, List, None]]) -> 'FingerprintConfig':
137137
"""Create config from dictionary format."""
138-
return cls(**data)
138+
return cls(**data) # type: ignore[arg-type]

pydoll/protocol/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
from typing import TypedDict
1+
from typing import Any, Dict, TypedDict, TypeVar
22

33
try:
44
from typing import NotRequired
55
except ImportError:
66
from typing_extensions import NotRequired
77

8+
T = TypeVar('T')
9+
810

911
class CommandParams(TypedDict, total=False):
1012
"""Base structure for all command parameters."""
@@ -47,4 +49,4 @@ class Event(TypedDict):
4749
"""Base structure for all events."""
4850

4951
method: str
50-
params: NotRequired[dict[str, str]]
52+
params: NotRequired[Dict[str, Any]]

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,4 +64,7 @@ post_test = 'coverage html'
6464
[tool.mypy]
6565
exclude = [
6666
"tests/",
67+
]
68+
disable_error_code = [
69+
"type-arg", # Disable "expects no type arguments" errors
6770
]

0 commit comments

Comments
 (0)