Commit 8a63bce
committed
refactor(typing): make
Unify the CDP/BiDi command model and tighten types end-to-end so the whole
package type-checks, while improving (not regressing) the public typing.
Core
- Unify Command into one generic TypedDict (protocol/base.py) with a phantom
`response: NotRequired[R]` field, so the response type is structurally
recoverable (mypy can't infer a TypedDict type arg that appears in no field);
re-exported from cdp/base and bidi/base. execute_command and
create_command_future are now generic (Command[P, R] -> R), dropping a
`# type: ignore`.
- FindElementsMixin is generic over the element type: Tab.find()/query() return
the concrete WebElement (CDP) / BiDiWebElement (BiDi) for full IDE
autocomplete, while the shared protocols use Sequence[WebElementProtocol] so
the concrete returns conform covariantly.
BiDi typing
- Discriminated unions via Literal `type` tags (input source actions,
EvaluateResult); typed source-action construction for mouse/keyboard/scroll
and element click.
- Real types for locateNodes params/result, ElementClipRectangle, and
cookie/proxy/intercept/window/download construction (no more dict
placeholders). Dynamic deserialization isolated to
_deserialize_remote_value(Mapping) -> object.
WebElement conformance
- WebElement and BiDiWebElement now satisfy WebElementProtocol; implemented
BiDiWebElement.get_children_elements / get_siblings_elements.
CDP↔generic convergence
- get_cookies/set_cookies convert between the portable Cookie types and CDP
(chromium/_cookies.py); CDP-only cookie fields stay reachable via the escape
hatch. set_window_bounds maps WindowBounds→Bounds; expect_download keeps the
CDP DEFAULT reset via the escape hatch.
Misc: edge.py Options→ChromiumOptions; guard the browser-WS port; CDP event
tracker stores raw dicts (drops two `# type: ignore`s).
Tests: realistic CDP cookie fakes in the cookie round-trips; new BiDi relations
integration test. Unit 407 green; BiDi + CDP cookie integration green.mypy pydoll clean (136 → 0) without weakening the API1 parent e56fee2 commit 8a63bce
31 files changed
Lines changed: 690 additions & 392 deletions
File tree
- pydoll
- browser
- chromium
- firefox
- connection
- managers
- elements
- bidi
- cdp
- mixins
- interactions
- protocol
- bidi
- browsing_context
- input
- script
- cdp
- tests
- integration
- unit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
41 | 43 | | |
42 | 44 | | |
43 | 45 | | |
44 | | - | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
| |||
433 | 434 | | |
434 | 435 | | |
435 | 436 | | |
436 | | - | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
437 | 440 | | |
438 | 441 | | |
439 | 442 | | |
| |||
448 | 451 | | |
449 | 452 | | |
450 | 453 | | |
451 | | - | |
| 454 | + | |
452 | 455 | | |
453 | 456 | | |
454 | 457 | | |
| |||
501 | 504 | | |
502 | 505 | | |
503 | 506 | | |
504 | | - | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
505 | 519 | | |
506 | 520 | | |
507 | 521 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
| |||
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
64 | | - | |
| 66 | + | |
| 67 | + | |
65 | 68 | | |
66 | 69 | | |
67 | 70 | | |
| |||
71 | 74 | | |
72 | 75 | | |
73 | 76 | | |
| 77 | + | |
74 | 78 | | |
75 | 79 | | |
76 | 80 | | |
| |||
791 | 795 | | |
792 | 796 | | |
793 | 797 | | |
794 | | - | |
| 798 | + | |
795 | 799 | | |
796 | 800 | | |
797 | 801 | | |
798 | 802 | | |
799 | 803 | | |
800 | 804 | | |
801 | | - | |
| 805 | + | |
802 | 806 | | |
803 | 807 | | |
804 | 808 | | |
| |||
858 | 862 | | |
859 | 863 | | |
860 | 864 | | |
861 | | - | |
| 865 | + | |
862 | 866 | | |
863 | 867 | | |
864 | 868 | | |
| |||
1115 | 1119 | | |
1116 | 1120 | | |
1117 | 1121 | | |
1118 | | - | |
1119 | | - | |
| 1122 | + | |
1120 | 1123 | | |
1121 | 1124 | | |
1122 | 1125 | | |
| |||
1519 | 1522 | | |
1520 | 1523 | | |
1521 | 1524 | | |
1522 | | - | |
1523 | | - | |
1524 | | - | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
1525 | 1530 | | |
1526 | 1531 | | |
1527 | 1532 | | |
| |||
0 commit comments