Skip to content

Commit 28c931d

Browse files
committed
document the differences in method signatures between impl and api
1 parent ecd0d43 commit 28c931d

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

CONTRIBUTING.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,61 @@ pre-commit run --all-files
4949

5050
For more details look at the [CI configuration](./blob/master/.github/workflows/ci.yml).
5151

52-
### Regenerating APIs
52+
### APIs
53+
54+
#### Regenerating
5355

5456
```bash
5557
./scripts/update_api.sh
5658
pre-commit run --all-files
5759
```
5860

61+
#### Differences between `_impl` and exposed API method signatures
62+
63+
- optional arguments are automatically converted to keyword arguments. for example:
64+
```py
65+
def wait_for_selector(self, selector: str, timeout: float = None, state: Literal["attached", "visible"] = None)
66+
```
67+
becomes
68+
```py
69+
def wait_for_selector(self, selector: str, *, timeout: float = None, state: Literal["attached", "visible"] = None)
70+
```
71+
72+
- overloads must be defined using `@api_overload` in order for the generate scripts to be able to see them at runtime.
73+
```py
74+
@api_overload
75+
async def wait_for_selector(
76+
self,
77+
selector: str,
78+
*,
79+
timeout: float = None,
80+
state: Literal["attached", "visible"] = None,
81+
strict: bool = None,
82+
) -> ElementHandle:
83+
pass
84+
85+
@api_overload # type: ignore[no-redef]
86+
async def wait_for_selector(
87+
self,
88+
selector: str,
89+
*,
90+
timeout: float = None,
91+
state: Literal["detached", "hidden"],
92+
strict: bool = None,
93+
) -> None:
94+
pass
95+
96+
async def wait_for_selector( # type: ignore[no-redef]
97+
self,
98+
selector: str,
99+
*,
100+
timeout: float = None,
101+
state: Literal["attached", "detached", "hidden", "visible"] = None,
102+
strict: bool = None,
103+
) -> Optional[ElementHandle]:
104+
...
105+
```
106+
59107
## Contributor License Agreement
60108

61109
This project welcomes contributions and suggestions. Most contributions require you to agree to a

0 commit comments

Comments
 (0)