Skip to content

Commit

Permalink
chore: update pre-commit (#1750)
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Feb 3, 2023
1 parent 6939e0f commit 4478925
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 29 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -15,7 +15,7 @@ repos:
- id: check-executables-have-shebangs
- id: check-merge-conflict
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.1.0
hooks:
- id: black
- repo: https://github.com/pre-commit/mirrors-mypy
Expand All @@ -28,7 +28,7 @@ repos:
hooks:
- id: flake8
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
- repo: local
Expand Down
1 change: 0 additions & 1 deletion playwright/_impl/_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@


class Browser(ChannelOwner):

Events = SimpleNamespace(
Disconnected="disconnected",
)
Expand Down
1 change: 0 additions & 1 deletion playwright/_impl/_browser_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@


class BrowserContext(ChannelOwner):

Events = SimpleNamespace(
BackgroundPage="backgroundpage",
Close="close",
Expand Down
1 change: 0 additions & 1 deletion playwright/_impl/_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ def frame(self) -> "Frame":


class WebSocket(ChannelOwner):

Events = SimpleNamespace(
Close="close",
FrameReceived="framereceived",
Expand Down
1 change: 0 additions & 1 deletion playwright/_impl/_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@


class Page(ChannelOwner):

Events = SimpleNamespace(
Close="close",
Crash="crash",
Expand Down
25 changes: 16 additions & 9 deletions playwright/async_api/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -7331,7 +7331,8 @@ def on(
page.on(\"dialog\", lambda dialog: dialog.accept())
```

**NOTE** When no `page.on('dialog')` listeners are present, all dialogs are automatically dismissed."""
**NOTE** When no `page.on('dialog')` listeners are present, all dialogs are automatically dismissed.
"""

@typing.overload
def on(
Expand All @@ -7341,7 +7342,8 @@ def on(
) -> None:
"""
Emitted when the JavaScript
[`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched."""
[`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched.
"""

@typing.overload
def on(
Expand Down Expand Up @@ -7403,7 +7405,8 @@ def on(
f: typing.Callable[["Page"], "typing.Union[typing.Awaitable[None], None]"],
) -> None:
"""
Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched."""
Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched.
"""

@typing.overload
def on(
Expand Down Expand Up @@ -7628,7 +7631,8 @@ def once(
page.on(\"dialog\", lambda dialog: dialog.accept())
```

**NOTE** When no `page.on('dialog')` listeners are present, all dialogs are automatically dismissed."""
**NOTE** When no `page.on('dialog')` listeners are present, all dialogs are automatically dismissed.
"""

@typing.overload
def once(
Expand All @@ -7638,7 +7642,8 @@ def once(
) -> None:
"""
Emitted when the JavaScript
[`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched."""
[`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched.
"""

@typing.overload
def once(
Expand Down Expand Up @@ -7700,7 +7705,8 @@ def once(
f: typing.Callable[["Page"], "typing.Union[typing.Awaitable[None], None]"],
) -> None:
"""
Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched."""
Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched.
"""

@typing.overload
def once(
Expand Down Expand Up @@ -12421,7 +12427,8 @@ def on(
Emitted when a request is issued from any pages created through this context. The [request] object is read-only. To
only listen for requests from a particular page, use `page.on('request')`.

In order to intercept and mutate requests, see `browser_context.route()` or `page.route()`."""
In order to intercept and mutate requests, see `browser_context.route()` or `page.route()`.
"""

@typing.overload
def on(
Expand Down Expand Up @@ -12552,7 +12559,8 @@ def once(
Emitted when a request is issued from any pages created through this context. The [request] object is read-only. To
only listen for requests from a particular page, use `page.on('request')`.

In order to intercept and mutate requests, see `browser_context.route()` or `page.route()`."""
In order to intercept and mutate requests, see `browser_context.route()` or `page.route()`.
"""

@typing.overload
def once(
Expand Down Expand Up @@ -14847,7 +14855,6 @@ def request(self) -> "APIRequest":
return mapping.from_impl(self._impl_obj.request)

def __getitem__(self, value: str) -> "BrowserType":

return mapping.from_impl(self._impl_obj.__getitem__(value=value))

def stop(self) -> None:
Expand Down
7 changes: 5 additions & 2 deletions playwright/sync_api/_context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import asyncio
import sys
from typing import Any, Optional, cast
from typing import TYPE_CHECKING, Any, Optional, cast

from greenlet import greenlet

Expand All @@ -26,13 +26,16 @@
from playwright._impl._transport import PipeTransport
from playwright.sync_api._generated import Playwright as SyncPlaywright

if TYPE_CHECKING:
from asyncio.unix_events import AbstractChildWatcher


class PlaywrightContextManager:
def __init__(self) -> None:
self._playwright: SyncPlaywright
self._loop: asyncio.AbstractEventLoop
self._own_loop = False
self._watcher: Optional[asyncio.AbstractChildWatcher] = None
self._watcher: Optional[AbstractChildWatcher] = None

def __enter__(self) -> SyncPlaywright:
try:
Expand Down
25 changes: 16 additions & 9 deletions playwright/sync_api/_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -7433,15 +7433,17 @@ def on(
page.on(\"dialog\", lambda dialog: dialog.accept())
```

**NOTE** When no `page.on('dialog')` listeners are present, all dialogs are automatically dismissed."""
**NOTE** When no `page.on('dialog')` listeners are present, all dialogs are automatically dismissed.
"""

@typing.overload
def on(
self, event: Literal["domcontentloaded"], f: typing.Callable[["Page"], "None"]
) -> None:
"""
Emitted when the JavaScript
[`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched."""
[`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched.
"""

@typing.overload
def on(
Expand Down Expand Up @@ -7487,7 +7489,8 @@ def on(
@typing.overload
def on(self, event: Literal["load"], f: typing.Callable[["Page"], "None"]) -> None:
"""
Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched."""
Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched.
"""

@typing.overload
def on(
Expand Down Expand Up @@ -7680,15 +7683,17 @@ def once(
page.on(\"dialog\", lambda dialog: dialog.accept())
```

**NOTE** When no `page.on('dialog')` listeners are present, all dialogs are automatically dismissed."""
**NOTE** When no `page.on('dialog')` listeners are present, all dialogs are automatically dismissed.
"""

@typing.overload
def once(
self, event: Literal["domcontentloaded"], f: typing.Callable[["Page"], "None"]
) -> None:
"""
Emitted when the JavaScript
[`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched."""
[`DOMContentLoaded`](https://developer.mozilla.org/en-US/docs/Web/Events/DOMContentLoaded) event is dispatched.
"""

@typing.overload
def once(
Expand Down Expand Up @@ -7736,7 +7741,8 @@ def once(
self, event: Literal["load"], f: typing.Callable[["Page"], "None"]
) -> None:
"""
Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched."""
Emitted when the JavaScript [`load`](https://developer.mozilla.org/en-US/docs/Web/Events/load) event is dispatched.
"""

@typing.overload
def once(
Expand Down Expand Up @@ -12515,7 +12521,8 @@ def on(
Emitted when a request is issued from any pages created through this context. The [request] object is read-only. To
only listen for requests from a particular page, use `page.on('request')`.

In order to intercept and mutate requests, see `browser_context.route()` or `page.route()`."""
In order to intercept and mutate requests, see `browser_context.route()` or `page.route()`.
"""

@typing.overload
def on(
Expand Down Expand Up @@ -12624,7 +12631,8 @@ def once(
Emitted when a request is issued from any pages created through this context. The [request] object is read-only. To
only listen for requests from a particular page, use `page.on('request')`.

In order to intercept and mutate requests, see `browser_context.route()` or `page.route()`."""
In order to intercept and mutate requests, see `browser_context.route()` or `page.route()`.
"""

@typing.overload
def once(
Expand Down Expand Up @@ -14931,7 +14939,6 @@ def request(self) -> "APIRequest":
return mapping.from_impl(self._impl_obj.request)

def __getitem__(self, value: str) -> "BrowserType":

return mapping.from_impl(self._impl_obj.__getitem__(value=value))

def stop(self) -> None:
Expand Down
1 change: 1 addition & 0 deletions scripts/generate_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ def return_value(value: Any) -> List[str]:
api_globals = globals()
assert Serializable


# Python 3.11+ does not treat default args with None as Optional anymore, this wrapper will still wrap them.
# https://github.com/python/cpython/issues/90353
def get_type_hints(func: Any, globalns: Any) -> Dict[str, Any]:
Expand Down
1 change: 0 additions & 1 deletion tests/async/test_har.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ async def test_should_fulfill_from_har_with_content_in_a_file(
async def test_should_round_trip_har_zip(
browser: Browser, server: Server, assetdir: Path, tmpdir: Path
) -> None:

har_path = tmpdir / "har.zip"
context_1 = await browser.new_context(
record_har_mode="minimal", record_har_path=har_path
Expand Down
1 change: 0 additions & 1 deletion tests/sync/test_har.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,6 @@ def test_should_fulfill_from_har_with_content_in_a_file(
def test_should_round_trip_har_zip(
browser: Browser, server: Server, assetdir: Path, tmpdir: Path
) -> None:

har_path = tmpdir / "har.zip"
context_1 = browser.new_context(record_har_mode="minimal", record_har_path=har_path)
page_1 = context_1.new_page()
Expand Down

0 comments on commit 4478925

Please sign in to comment.