Skip to content

Commit 7d2facb

Browse files
CopilotP4X-ng
andcommitted
Merge PR #22: Update dependencies and regenerate CDP bindings for 0.4.0
Co-authored-by: P4X-ng <223870169+P4X-ng@users.noreply.github.com>
1 parent dc5ebe6 commit 7d2facb

36 files changed

Lines changed: 1268 additions & 2288 deletions

generator/generate.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,27 @@ def format_annotation(current_module: types.ModuleType, ann: typing.Any):
140140
ann_str = f'{ann.__module__}.{ann.__name__}'
141141
else:
142142
ann_str = ann.__name__
143-
elif ann._name == 'Any':
143+
elif hasattr(ann, '_name') and ann._name == 'Any':
144144
ann_str = 'typing.Any'
145-
elif ann._name == 'List':
145+
elif hasattr(ann, '_name') and ann._name == 'List':
146146
nested_ann = format_annotation(current_module, ann.__args__[0])
147147
ann_str = f'typing.List[{nested_ann}]'
148-
elif ann._name == 'Tuple':
148+
elif hasattr(ann, '_name') and ann._name == 'Dict':
149+
key_ann = format_annotation(current_module, ann.__args__[0])
150+
val_ann = format_annotation(current_module, ann.__args__[1])
151+
ann_str = f'typing.Dict[{key_ann}, {val_ann}]'
152+
elif hasattr(ann, '_name') and ann._name == 'Tuple':
149153
nested_anns = ', '.join(format_annotation(current_module, a) for a in ann.__args__)
150154
ann_str = f'typing.Tuple[{nested_anns}]'
151-
elif ann._name is None and len(ann.__args__) > 1:
155+
elif hasattr(ann, '_name') and ann._name == 'Generator':
156+
nested_anns = ', '.join(format_annotation(current_module, a) for a in ann.__args__)
157+
ann_str = f'typing.Generator[{nested_anns}]'
158+
elif hasattr(ann, '_name') and ann._name == 'Optional':
159+
# Optional is actually Union[X, None]
160+
opt_type = [a for a in ann.__args__ if a is not type(None)][0]
161+
nested_ann = format_annotation(current_module, opt_type)
162+
ann_str = f'typing.Optional[{nested_ann}]'
163+
elif hasattr(ann, '_name') and ann._name is None and hasattr(ann, '__args__') and len(ann.__args__) > 1:
152164
# For some reason union annotations don't have a name?
153165
# If the union has two members and one of them is NoneType, then it's really
154166
# a typing.Optional.

poetry.lock

Lines changed: 963 additions & 734 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ classifiers = [
1616
[tool.poetry.dependencies]
1717
python = "^3.7"
1818
chrome-devtools-protocol = "^0.4.0"
19-
trio = "^0.13.0"
20-
trio_websocket = "^0.8.0"
19+
trio = "^0.22.0"
20+
trio_websocket = "^0.9.0"
2121

22-
[tool.poetry.dev-dependencies]
23-
mypy = "^0.770"
24-
pytest = "^5.4.1"
25-
pytest-cov = "^2.8.1"
26-
pytest-trio = "^0.5.2"
22+
[tool.poetry.group.dev.dependencies]
23+
mypy = "^1.0"
24+
pytest = "^7.0"
25+
pytest-cov = "^4.0"
26+
pytest-trio = "^0.8.0"
2727
sphinx = "^3.0.1"
2828
sphinx-rtd-theme = "^0.4.3"
2929
sphinx-autodoc-typehints = "^1.10.3"

trio_cdp/generated/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
from . import accessibility
77
from . import animation
8+
from . import application_cache
89
from . import audits
910
from . import background_service
1011
from . import browser
@@ -20,7 +21,6 @@
2021
from . import dom_snapshot
2122
from . import dom_storage
2223
from . import emulation
23-
from . import event_breakpoints
2424
from . import fetch
2525
from . import headless_experimental
2626
from . import heap_profiler
@@ -30,13 +30,11 @@
3030
from . import io
3131
from . import layer_tree
3232
from . import log
33-
from . import media
3433
from . import memory
3534
from . import network
3635
from . import overlay
3736
from . import page
3837
from . import performance
39-
from . import performance_timeline
4038
from . import profiler
4139
from . import runtime
4240
from . import schema

trio_cdp/generated/accessibility.py

Lines changed: 4 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
AXValueNativeSourceType,
2020
AXValueSource,
2121
AXValueSourceType,
22-
AXValueType,
23-
LoadComplete,
24-
NodesUpdated
22+
AXValueType
2523
)
2624

2725

@@ -42,61 +40,16 @@ async def enable() -> None:
4240
return await session.execute(cdp.accessibility.enable())
4341

4442

45-
async def get_ax_node_and_ancestors(
46-
node_id: typing.Optional[cdp.dom.NodeId] = None,
47-
backend_node_id: typing.Optional[cdp.dom.BackendNodeId] = None,
48-
object_id: typing.Optional[cdp.runtime.RemoteObjectId] = None
49-
) -> typing.List[AXNode]:
50-
r'''
51-
Fetches a node and all ancestors up to and including the root.
52-
Requires ``enable()`` to have been called previously.
53-
54-
**EXPERIMENTAL**
55-
56-
:param node_id: *(Optional)* Identifier of the node to get.
57-
:param backend_node_id: *(Optional)* Identifier of the backend node to get.
58-
:param object_id: *(Optional)* JavaScript object id of the node wrapper to get.
59-
:returns:
60-
'''
61-
session = get_session_context('accessibility.get_ax_node_and_ancestors')
62-
return await session.execute(cdp.accessibility.get_ax_node_and_ancestors(node_id, backend_node_id, object_id))
63-
64-
65-
async def get_child_ax_nodes(
66-
id_: AXNodeId,
67-
frame_id: typing.Optional[cdp.page.FrameId] = None
68-
) -> typing.List[AXNode]:
69-
r'''
70-
Fetches a particular accessibility node by AXNodeId.
71-
Requires ``enable()`` to have been called previously.
72-
73-
**EXPERIMENTAL**
74-
75-
:param id_:
76-
:param frame_id: *(Optional)* The frame in whose document the node resides. If omitted, the root frame is used.
77-
:returns:
78-
'''
79-
session = get_session_context('accessibility.get_child_ax_nodes')
80-
return await session.execute(cdp.accessibility.get_child_ax_nodes(id_, frame_id))
81-
82-
83-
async def get_full_ax_tree(
84-
depth: typing.Optional[int] = None,
85-
max_depth: typing.Optional[int] = None,
86-
frame_id: typing.Optional[cdp.page.FrameId] = None
87-
) -> typing.List[AXNode]:
43+
async def get_full_ax_tree() -> typing.List[AXNode]:
8844
r'''
89-
Fetches the entire accessibility tree for the root Document
45+
Fetches the entire accessibility tree
9046
9147
**EXPERIMENTAL**
9248
93-
:param depth: *(Optional)* The maximum depth at which descendants of the root node should be retrieved. If omitted, the full tree is returned.
94-
:param max_depth: **(DEPRECATED)** *(Optional)* Deprecated. This parameter has been renamed to ```depth```. If depth is not provided, max_depth will be used.
95-
:param frame_id: *(Optional)* The frame for whose document the AX tree should be retrieved. If omited, the root frame is used.
9649
:returns:
9750
'''
9851
session = get_session_context('accessibility.get_full_ax_tree')
99-
return await session.execute(cdp.accessibility.get_full_ax_tree(depth, max_depth, frame_id))
52+
return await session.execute(cdp.accessibility.get_full_ax_tree())
10053

10154

10255
async def get_partial_ax_tree(
@@ -118,46 +71,3 @@ async def get_partial_ax_tree(
11871
'''
11972
session = get_session_context('accessibility.get_partial_ax_tree')
12073
return await session.execute(cdp.accessibility.get_partial_ax_tree(node_id, backend_node_id, object_id, fetch_relatives))
121-
122-
123-
async def get_root_ax_node(
124-
frame_id: typing.Optional[cdp.page.FrameId] = None
125-
) -> AXNode:
126-
r'''
127-
Fetches the root node.
128-
Requires ``enable()`` to have been called previously.
129-
130-
**EXPERIMENTAL**
131-
132-
:param frame_id: *(Optional)* The frame in whose document the node resides. If omitted, the root frame is used.
133-
:returns:
134-
'''
135-
session = get_session_context('accessibility.get_root_ax_node')
136-
return await session.execute(cdp.accessibility.get_root_ax_node(frame_id))
137-
138-
139-
async def query_ax_tree(
140-
node_id: typing.Optional[cdp.dom.NodeId] = None,
141-
backend_node_id: typing.Optional[cdp.dom.BackendNodeId] = None,
142-
object_id: typing.Optional[cdp.runtime.RemoteObjectId] = None,
143-
accessible_name: typing.Optional[str] = None,
144-
role: typing.Optional[str] = None
145-
) -> typing.List[AXNode]:
146-
r'''
147-
Query a DOM node's accessibility subtree for accessible name and role.
148-
This command computes the name and role for all nodes in the subtree, including those that are
149-
ignored for accessibility, and returns those that mactch the specified name and role. If no DOM
150-
node is specified, or the DOM node does not exist, the command returns an error. If neither
151-
``accessibleName`` or ``role`` is specified, it returns all the accessibility nodes in the subtree.
152-
153-
**EXPERIMENTAL**
154-
155-
:param node_id: *(Optional)* Identifier of the node for the root to query.
156-
:param backend_node_id: *(Optional)* Identifier of the backend node for the root to query.
157-
:param object_id: *(Optional)* JavaScript object id of the node wrapper for the root to query.
158-
:param accessible_name: *(Optional)* Find nodes with this computed name.
159-
:param role: *(Optional)* Find nodes with this computed role.
160-
:returns: A list of ``Accessibility.AXNode`` matching the specified attributes, including nodes that are ignored for accessibility.
161-
'''
162-
session = get_session_context('accessibility.query_ax_tree')
163-
return await session.execute(cdp.accessibility.query_ax_tree(node_id, backend_node_id, object_id, accessible_name, role))
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# DO NOT EDIT THIS FILE!
2+
#
3+
# This code is generated off of PyCDP modules. If you need to make
4+
# changes, edit the generator and regenerate all of the modules.
5+
6+
from __future__ import annotations
7+
import typing
8+
9+
from ..context import get_connection_context, get_session_context
10+
11+
import cdp.application_cache
12+
from cdp.application_cache import (
13+
ApplicationCache,
14+
ApplicationCacheResource,
15+
ApplicationCacheStatusUpdated,
16+
FrameWithManifest,
17+
NetworkStateUpdated
18+
)
19+
20+
21+
async def enable() -> None:
22+
r'''
23+
Enables application cache domain notifications.
24+
'''
25+
session = get_session_context('application_cache.enable')
26+
return await session.execute(cdp.application_cache.enable())
27+
28+
29+
async def get_application_cache_for_frame(
30+
frame_id: cdp.page.FrameId
31+
) -> ApplicationCache:
32+
r'''
33+
Returns relevant application cache data for the document in given frame.
34+
35+
:param frame_id: Identifier of the frame containing document whose application cache is retrieved.
36+
:returns: Relevant application cache data for the document in given frame.
37+
'''
38+
session = get_session_context('application_cache.get_application_cache_for_frame')
39+
return await session.execute(cdp.application_cache.get_application_cache_for_frame(frame_id))
40+
41+
42+
async def get_frames_with_manifests() -> typing.List[FrameWithManifest]:
43+
r'''
44+
Returns array of frame identifiers with manifest urls for each frame containing a document
45+
associated with some application cache.
46+
47+
:returns: Array of frame identifiers with manifest urls for each frame containing a document associated with some application cache.
48+
'''
49+
session = get_session_context('application_cache.get_frames_with_manifests')
50+
return await session.execute(cdp.application_cache.get_frames_with_manifests())
51+
52+
53+
async def get_manifest_for_frame(
54+
frame_id: cdp.page.FrameId
55+
) -> str:
56+
r'''
57+
Returns manifest URL for document in the given frame.
58+
59+
:param frame_id: Identifier of the frame containing document whose manifest is retrieved.
60+
:returns: Manifest URL for document in the given frame.
61+
'''
62+
session = get_session_context('application_cache.get_manifest_for_frame')
63+
return await session.execute(cdp.application_cache.get_manifest_for_frame(frame_id))

trio_cdp/generated/audits.py

Lines changed: 1 addition & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -9,78 +9,6 @@
99
from ..context import get_connection_context, get_session_context
1010

1111
import cdp.audits
12-
from cdp.audits import (
13-
AffectedCookie,
14-
AffectedFrame,
15-
AffectedRequest,
16-
AttributionReportingIssueDetails,
17-
AttributionReportingIssueType,
18-
BlockedByResponseIssueDetails,
19-
BlockedByResponseReason,
20-
ClientHintIssueDetails,
21-
ClientHintIssueReason,
22-
ContentSecurityPolicyIssueDetails,
23-
ContentSecurityPolicyViolationType,
24-
CorsIssueDetails,
25-
DeprecationIssueDetails,
26-
GenericIssueDetails,
27-
GenericIssueErrorType,
28-
HeavyAdIssueDetails,
29-
HeavyAdReason,
30-
HeavyAdResolutionStatus,
31-
InspectorIssue,
32-
InspectorIssueCode,
33-
InspectorIssueDetails,
34-
IssueAdded,
35-
IssueId,
36-
LowTextContrastIssueDetails,
37-
MixedContentIssueDetails,
38-
MixedContentResolutionStatus,
39-
MixedContentResourceType,
40-
NavigatorUserAgentIssueDetails,
41-
QuirksModeIssueDetails,
42-
SameSiteCookieExclusionReason,
43-
SameSiteCookieIssueDetails,
44-
SameSiteCookieOperation,
45-
SameSiteCookieWarningReason,
46-
SharedArrayBufferIssueDetails,
47-
SharedArrayBufferIssueType,
48-
SourceCodeLocation,
49-
TrustedWebActivityIssueDetails,
50-
TwaQualityEnforcementViolationType,
51-
WasmCrossOriginModuleSharingIssueDetails
52-
)
53-
54-
55-
async def check_contrast(
56-
report_aaa: typing.Optional[bool] = None
57-
) -> None:
58-
r'''
59-
Runs the contrast check for the target page. Found issues are reported
60-
using Audits.issueAdded event.
61-
62-
:param report_aaa: *(Optional)* Whether to report WCAG AAA level issues. Default is false.
63-
'''
64-
session = get_session_context('audits.check_contrast')
65-
return await session.execute(cdp.audits.check_contrast(report_aaa))
66-
67-
68-
async def disable() -> None:
69-
r'''
70-
Disables issues domain, prevents further issues from being reported to the client.
71-
'''
72-
session = get_session_context('audits.disable')
73-
return await session.execute(cdp.audits.disable())
74-
75-
76-
async def enable() -> None:
77-
r'''
78-
Enables issues domain, sends the issues collected so far to the client by means of the
79-
``issueAdded`` event.
80-
'''
81-
session = get_session_context('audits.enable')
82-
return await session.execute(cdp.audits.enable())
83-
8412

8513
async def get_encoded_response(
8614
request_id: cdp.network.RequestId,
@@ -98,7 +26,7 @@ async def get_encoded_response(
9826
:param size_only: *(Optional)* Whether to only return the size information (defaults to false).
9927
:returns: A tuple with the following items:
10028
101-
0. **body** - *(Optional)* The encoded body as a base64 string. Omitted if sizeOnly is true. (Encoded as a base64 string when passed over JSON)
29+
0. **body** - *(Optional)* The encoded body as a base64 string. Omitted if sizeOnly is true.
10230
1. **originalSize** - Size before re-encoding.
10331
2. **encodedSize** - Size after re-encoding.
10432
'''

0 commit comments

Comments
 (0)