Skip to content

Commit 23a225e

Browse files
authored
chore: enforce no underscores in impl class params (#2223)
1 parent d943ab8 commit 23a225e

File tree

10 files changed

+230
-231
lines changed

10 files changed

+230
-231
lines changed

playwright/_impl/_assertions.py

Lines changed: 39 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -89,45 +89,45 @@ def _not(self) -> "PageAssertions":
8989
)
9090

9191
async def to_have_title(
92-
self, title_or_reg_exp: Union[Pattern[str], str], timeout: float = None
92+
self, titleOrRegExp: Union[Pattern[str], str], timeout: float = None
9393
) -> None:
9494
expected_values = to_expected_text_values(
95-
[title_or_reg_exp], normalize_white_space=True
95+
[titleOrRegExp], normalize_white_space=True
9696
)
9797
__tracebackhide__ = True
9898
await self._expect_impl(
9999
"to.have.title",
100100
FrameExpectOptions(expectedText=expected_values, timeout=timeout),
101-
title_or_reg_exp,
101+
titleOrRegExp,
102102
"Page title expected to be",
103103
)
104104

105105
async def not_to_have_title(
106-
self, title_or_reg_exp: Union[Pattern[str], str], timeout: float = None
106+
self, titleOrRegExp: Union[Pattern[str], str], timeout: float = None
107107
) -> None:
108108
__tracebackhide__ = True
109-
await self._not.to_have_title(title_or_reg_exp, timeout)
109+
await self._not.to_have_title(titleOrRegExp, timeout)
110110

111111
async def to_have_url(
112-
self, url_or_reg_exp: Union[str, Pattern[str]], timeout: float = None
112+
self, urlOrRegExp: Union[str, Pattern[str]], timeout: float = None
113113
) -> None:
114114
__tracebackhide__ = True
115115
base_url = self._actual_page.context._options.get("baseURL")
116-
if isinstance(url_or_reg_exp, str) and base_url:
117-
url_or_reg_exp = urljoin(base_url, url_or_reg_exp)
118-
expected_text = to_expected_text_values([url_or_reg_exp])
116+
if isinstance(urlOrRegExp, str) and base_url:
117+
urlOrRegExp = urljoin(base_url, urlOrRegExp)
118+
expected_text = to_expected_text_values([urlOrRegExp])
119119
await self._expect_impl(
120120
"to.have.url",
121121
FrameExpectOptions(expectedText=expected_text, timeout=timeout),
122-
url_or_reg_exp,
122+
urlOrRegExp,
123123
"Page URL expected to be",
124124
)
125125

126126
async def not_to_have_url(
127-
self, url_or_reg_exp: Union[Pattern[str], str], timeout: float = None
127+
self, urlOrRegExp: Union[Pattern[str], str], timeout: float = None
128128
) -> None:
129129
__tracebackhide__ = True
130-
await self._not.to_have_url(url_or_reg_exp, timeout)
130+
await self._not.to_have_url(urlOrRegExp, timeout)
131131

132132

133133
class LocatorAssertions(AssertionsBase):
@@ -156,9 +156,9 @@ async def to_contain_text(
156156
Pattern[str],
157157
str,
158158
],
159-
use_inner_text: bool = None,
159+
useInnerText: bool = None,
160160
timeout: float = None,
161-
ignore_case: bool = None,
161+
ignoreCase: bool = None,
162162
) -> None:
163163
__tracebackhide__ = True
164164
if isinstance(expected, collections.abc.Sequence) and not isinstance(
@@ -168,13 +168,13 @@ async def to_contain_text(
168168
expected,
169169
match_substring=True,
170170
normalize_white_space=True,
171-
ignore_case=ignore_case,
171+
ignoreCase=ignoreCase,
172172
)
173173
await self._expect_impl(
174174
"to.contain.text.array",
175175
FrameExpectOptions(
176176
expectedText=expected_text,
177-
useInnerText=use_inner_text,
177+
useInnerText=useInnerText,
178178
timeout=timeout,
179179
),
180180
expected,
@@ -185,13 +185,13 @@ async def to_contain_text(
185185
[expected],
186186
match_substring=True,
187187
normalize_white_space=True,
188-
ignore_case=ignore_case,
188+
ignoreCase=ignoreCase,
189189
)
190190
await self._expect_impl(
191191
"to.have.text",
192192
FrameExpectOptions(
193193
expectedText=expected_text,
194-
useInnerText=use_inner_text,
194+
useInnerText=useInnerText,
195195
timeout=timeout,
196196
),
197197
expected,
@@ -207,22 +207,22 @@ async def not_to_contain_text(
207207
Pattern[str],
208208
str,
209209
],
210-
use_inner_text: bool = None,
210+
useInnerText: bool = None,
211211
timeout: float = None,
212-
ignore_case: bool = None,
212+
ignoreCase: bool = None,
213213
) -> None:
214214
__tracebackhide__ = True
215-
await self._not.to_contain_text(expected, use_inner_text, timeout, ignore_case)
215+
await self._not.to_contain_text(expected, useInnerText, timeout, ignoreCase)
216216

217217
async def to_have_attribute(
218218
self,
219219
name: str,
220220
value: Union[str, Pattern[str]],
221-
ignore_case: bool = None,
221+
ignoreCase: bool = None,
222222
timeout: float = None,
223223
) -> None:
224224
__tracebackhide__ = True
225-
expected_text = to_expected_text_values([value], ignore_case=ignore_case)
225+
expected_text = to_expected_text_values([value], ignoreCase=ignoreCase)
226226
await self._expect_impl(
227227
"to.have.attribute.value",
228228
FrameExpectOptions(
@@ -236,12 +236,12 @@ async def not_to_have_attribute(
236236
self,
237237
name: str,
238238
value: Union[str, Pattern[str]],
239-
ignore_case: bool = None,
239+
ignoreCase: bool = None,
240240
timeout: float = None,
241241
) -> None:
242242
__tracebackhide__ = True
243243
await self._not.to_have_attribute(
244-
name, value, ignore_case=ignore_case, timeout=timeout
244+
name, value, ignoreCase=ignoreCase, timeout=timeout
245245
)
246246

247247
async def to_have_class(
@@ -440,9 +440,9 @@ async def to_have_text(
440440
Pattern[str],
441441
str,
442442
],
443-
use_inner_text: bool = None,
443+
useInnerText: bool = None,
444444
timeout: float = None,
445-
ignore_case: bool = None,
445+
ignoreCase: bool = None,
446446
) -> None:
447447
__tracebackhide__ = True
448448
if isinstance(expected, collections.abc.Sequence) and not isinstance(
@@ -451,27 +451,27 @@ async def to_have_text(
451451
expected_text = to_expected_text_values(
452452
expected,
453453
normalize_white_space=True,
454-
ignore_case=ignore_case,
454+
ignoreCase=ignoreCase,
455455
)
456456
await self._expect_impl(
457457
"to.have.text.array",
458458
FrameExpectOptions(
459459
expectedText=expected_text,
460-
useInnerText=use_inner_text,
460+
useInnerText=useInnerText,
461461
timeout=timeout,
462462
),
463463
expected,
464464
"Locator expected to have text",
465465
)
466466
else:
467467
expected_text = to_expected_text_values(
468-
[expected], normalize_white_space=True, ignore_case=ignore_case
468+
[expected], normalize_white_space=True, ignoreCase=ignoreCase
469469
)
470470
await self._expect_impl(
471471
"to.have.text",
472472
FrameExpectOptions(
473473
expectedText=expected_text,
474-
useInnerText=use_inner_text,
474+
useInnerText=useInnerText,
475475
timeout=timeout,
476476
),
477477
expected,
@@ -487,12 +487,12 @@ async def not_to_have_text(
487487
Pattern[str],
488488
str,
489489
],
490-
use_inner_text: bool = None,
490+
useInnerText: bool = None,
491491
timeout: float = None,
492-
ignore_case: bool = None,
492+
ignoreCase: bool = None,
493493
) -> None:
494494
__tracebackhide__ = True
495-
await self._not.to_have_text(expected, use_inner_text, timeout, ignore_case)
495+
await self._not.to_have_text(expected, useInnerText, timeout, ignoreCase)
496496

497497
async def to_be_attached(
498498
self,
@@ -754,14 +754,14 @@ def expected_regex(
754754
pattern: Pattern[str],
755755
match_substring: bool,
756756
normalize_white_space: bool,
757-
ignore_case: Optional[bool] = None,
757+
ignoreCase: Optional[bool] = None,
758758
) -> ExpectedTextValue:
759759
expected = ExpectedTextValue(
760760
regexSource=pattern.pattern,
761761
regexFlags=escape_regex_flags(pattern),
762762
matchSubstring=match_substring,
763763
normalizeWhiteSpace=normalize_white_space,
764-
ignoreCase=ignore_case,
764+
ignoreCase=ignoreCase,
765765
)
766766
if expected["ignoreCase"] is None:
767767
del expected["ignoreCase"]
@@ -774,7 +774,7 @@ def to_expected_text_values(
774774
],
775775
match_substring: bool = False,
776776
normalize_white_space: bool = False,
777-
ignore_case: Optional[bool] = None,
777+
ignoreCase: Optional[bool] = None,
778778
) -> Sequence[ExpectedTextValue]:
779779
out: List[ExpectedTextValue] = []
780780
assert isinstance(items, list)
@@ -784,15 +784,13 @@ def to_expected_text_values(
784784
string=item,
785785
matchSubstring=match_substring,
786786
normalizeWhiteSpace=normalize_white_space,
787-
ignoreCase=ignore_case,
787+
ignoreCase=ignoreCase,
788788
)
789789
if o["ignoreCase"] is None:
790790
del o["ignoreCase"]
791791
out.append(o)
792792
elif isinstance(item, Pattern):
793793
out.append(
794-
expected_regex(
795-
item, match_substring, normalize_white_space, ignore_case
796-
)
794+
expected_regex(item, match_substring, normalize_white_space, ignoreCase)
797795
)
798796
return out

playwright/_impl/_browser_context.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -399,24 +399,24 @@ async def route_from_har(
399399
self,
400400
har: Union[Path, str],
401401
url: Union[Pattern[str], str] = None,
402-
not_found: RouteFromHarNotFoundPolicy = None,
402+
notFound: RouteFromHarNotFoundPolicy = None,
403403
update: bool = None,
404-
update_content: Literal["attach", "embed"] = None,
405-
update_mode: HarMode = None,
404+
updateContent: Literal["attach", "embed"] = None,
405+
updateMode: HarMode = None,
406406
) -> None:
407407
if update:
408408
await self._record_into_har(
409409
har=har,
410410
page=None,
411411
url=url,
412-
update_content=update_content,
413-
update_mode=update_mode,
412+
update_content=updateContent,
413+
update_mode=updateMode,
414414
)
415415
return
416416
router = await HarRouter.create(
417417
local_utils=self._connection.local_utils,
418418
file=str(har),
419-
not_found_action=not_found or "abort",
419+
not_found_action=notFound or "abort",
420420
url_matcher=url,
421421
)
422422
await router.add_context_route(self)

playwright/_impl/_browser_type.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,28 +183,28 @@ async def connect_over_cdp(
183183

184184
async def connect(
185185
self,
186-
ws_endpoint: str,
186+
wsEndpoint: str,
187187
timeout: float = None,
188-
slow_mo: float = None,
188+
slowMo: float = None,
189189
headers: Dict[str, str] = None,
190-
expose_network: str = None,
190+
exposeNetwork: str = None,
191191
) -> Browser:
192192
if timeout is None:
193193
timeout = 30000
194-
if slow_mo is None:
195-
slow_mo = 0
194+
if slowMo is None:
195+
slowMo = 0
196196

197197
headers = {**(headers if headers else {}), "x-playwright-browser": self.name}
198198
local_utils = self._connection.local_utils
199199
pipe_channel = (
200200
await local_utils._channel.send_return_as_dict(
201201
"connect",
202202
{
203-
"wsEndpoint": ws_endpoint,
203+
"wsEndpoint": wsEndpoint,
204204
"headers": headers,
205-
"slowMo": slow_mo,
205+
"slowMo": slowMo,
206206
"timeout": timeout,
207-
"exposeNetwork": expose_network,
207+
"exposeNetwork": exposeNetwork,
208208
},
209209
)
210210
)["pipe"]

playwright/_impl/_frame.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -175,20 +175,20 @@ def _setup_navigation_waiter(self, wait_name: str, timeout: float = None) -> Wai
175175
def expect_navigation(
176176
self,
177177
url: URLMatch = None,
178-
wait_until: DocumentLoadState = None,
178+
waitUntil: DocumentLoadState = None,
179179
timeout: float = None,
180180
) -> EventContextManagerImpl[Response]:
181181
assert self._page
182-
if not wait_until:
183-
wait_until = "load"
182+
if not waitUntil:
183+
waitUntil = "load"
184184

185185
if timeout is None:
186186
timeout = self._page._timeout_settings.navigation_timeout()
187187
deadline = monotonic_time() + timeout
188188
waiter = self._setup_navigation_waiter("expect_navigation", timeout)
189189

190190
to_url = f' to "{url}"' if url else ""
191-
waiter.log(f"waiting for navigation{to_url} until '{wait_until}'")
191+
waiter.log(f"waiting for navigation{to_url} until '{waitUntil}'")
192192
matcher = (
193193
URLMatcher(self._page._browser_context._options.get("baseURL"), url)
194194
if url
@@ -212,10 +212,10 @@ async def continuation() -> Optional[Response]:
212212
event = await waiter.result()
213213
if "error" in event:
214214
raise Error(event["error"])
215-
if wait_until not in self._load_states:
215+
if waitUntil not in self._load_states:
216216
t = deadline - monotonic_time()
217217
if t > 0:
218-
await self._wait_for_load_state_impl(state=wait_until, timeout=t)
218+
await self._wait_for_load_state_impl(state=waitUntil, timeout=t)
219219
if "newDocument" in event and "request" in event["newDocument"]:
220220
request = from_channel(event["newDocument"]["request"])
221221
return await request.response()
@@ -226,16 +226,16 @@ async def continuation() -> Optional[Response]:
226226
async def wait_for_url(
227227
self,
228228
url: URLMatch,
229-
wait_until: DocumentLoadState = None,
229+
waitUntil: DocumentLoadState = None,
230230
timeout: float = None,
231231
) -> None:
232232
assert self._page
233233
matcher = URLMatcher(self._page._browser_context._options.get("baseURL"), url)
234234
if matcher.matches(self.url):
235-
await self._wait_for_load_state_impl(state=wait_until, timeout=timeout)
235+
await self._wait_for_load_state_impl(state=waitUntil, timeout=timeout)
236236
return
237237
async with self.expect_navigation(
238-
url=url, wait_until=wait_until, timeout=timeout
238+
url=url, waitUntil=waitUntil, timeout=timeout
239239
):
240240
pass
241241

@@ -535,18 +535,18 @@ async def fill(
535535
def locator(
536536
self,
537537
selector: str,
538-
has_text: Union[str, Pattern[str]] = None,
539-
has_not_text: Union[str, Pattern[str]] = None,
538+
hasText: Union[str, Pattern[str]] = None,
539+
hasNotText: Union[str, Pattern[str]] = None,
540540
has: Locator = None,
541-
has_not: Locator = None,
541+
hasNot: Locator = None,
542542
) -> Locator:
543543
return Locator(
544544
self,
545545
selector,
546-
has_text=has_text,
547-
has_not_text=has_not_text,
546+
has_text=hasText,
547+
has_not_text=hasNotText,
548548
has=has,
549-
has_not=has_not,
549+
has_not=hasNot,
550550
)
551551

552552
def get_by_alt_text(

0 commit comments

Comments
 (0)