Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ Breaking changes are listed first in each release.

### Breaking changes

- Renamed the error module from `cdpify.exceptions` to `cdpify.error`.
Update imports such as `from cdpify.exceptions import CDPCommandError` to
`from cdpify.error import CDPCommandError`. The old module is removed;
error classes remain available from the root package (`from cdpify import
CDPCommandError`) with the same behavior and inheritance.
- Optional `any` fields now default to `UNSET`, distinguishing omission from
JSON `null`. For example, `CallArgument()` omits `value`, while
`CallArgument(value=None)` sends `{"value": null}`. Ordinary optional scalar
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@ than `FrameId("F1")`, and `isinstance(frame_id, str)` for a runtime check.

### When Chrome deviates from the spec

Library error classes are available from `cdpify.error` and the root package:

```python
from cdpify.error import CDPCommandError, CDPDecodeError
```

Missing required fields raise `CDPDecodeError` with `model_type`,
`missing_fields` and the enclosing wire-field `path`. Unknown fields are ignored
and future enum values remain supported. Decoding checks required field
Expand Down
6 changes: 3 additions & 3 deletions cdpify/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from .client import CdpClient
from .codec import decode_cdp, encode_cdp
from .event_queue import OverflowPolicy
from .events import EventSubscription, ReceivedEvent
from .exceptions import (
from .error import (
CDPCommandError,
CDPConnectionError,
CDPDecodeError,
Expand All @@ -12,6 +10,8 @@
CDPTimeoutError,
deprecated_exception,
)
from .event_queue import OverflowPolicy
from .events import EventSubscription, ReceivedEvent
from .executor import CommandExecutor
from .session import CdpSession
from .transport import Transport, TransportEvent
Expand Down
2 changes: 1 addition & 1 deletion cdpify/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from typing import Any, Literal, Self

from cdpify.domains import DomainAccessors
from cdpify.error import CDPConnectionError
from cdpify.event_queue import OverflowPolicy
from cdpify.events import EventRouter, EventSubscription, ReceivedEvent
from cdpify.events.source import EventSource
from cdpify.exceptions import CDPConnectionError
from cdpify.executor import BoundCommandExecutor
from cdpify.session import CdpSession
from cdpify.transport import CallbackTransport, Transport, TransportEvent
Expand Down
2 changes: 1 addition & 1 deletion cdpify/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from types import UnionType
from typing import Any, TypeAliasType, Union, get_args, get_origin, get_type_hints

from cdpify.exceptions import CDPDecodeError
from cdpify.error import CDPDecodeError
from cdpify.unset import UNSET

logger = logging.getLogger(__name__)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion cdpify/event_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from collections import deque
from typing import Literal

from cdpify.exceptions import CDPEventOverflowError
from cdpify.error import CDPEventOverflowError

type OverflowPolicy = Literal["error", "drop_oldest"]

Expand Down
2 changes: 1 addition & 1 deletion cdpify/events/subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from types import TracebackType
from typing import Self

from cdpify.error import CDPEventOverflowError, CDPStreamClosedError
from cdpify.event_queue import EventQueue
from cdpify.exceptions import CDPEventOverflowError, CDPStreamClosedError
from cdpify.unset import UNSET, UnsetType

from .dispatcher import RawCDPEvent
Expand Down
2 changes: 1 addition & 1 deletion cdpify/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from collections.abc import Awaitable
from typing import Any, Protocol

from cdpify.exceptions import CDPTimeoutError
from cdpify.error import CDPTimeoutError
from cdpify.transport import Transport
from cdpify.unset import UNSET, UnsetType

Expand Down
2 changes: 1 addition & 1 deletion cdpify/transports/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import websockets
from websockets.asyncio.client import ClientConnection, connect

from cdpify.error import CDPCommandError, CDPConnectionError
from cdpify.event_queue import EventQueue, OverflowPolicy
from cdpify.exceptions import CDPCommandError, CDPConnectionError
from cdpify.executor import _with_timeout
from cdpify.transport import EventHandler, TransportEvent

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import pytest

import cdpify
from cdpify import exceptions
from cdpify.exceptions import CDPCommandError, CDPTimeoutError
from cdpify import error
from cdpify.error import CDPCommandError, CDPTimeoutError
from cdpify.shared.decorators import _Deprecated, deprecated


Expand Down Expand Up @@ -32,7 +32,7 @@ def test_timeout_error_is_builtin_timeout_error() -> None:
assert issubclass(CDPTimeoutError, TimeoutError)


@pytest.mark.parametrize("module", [cdpify, exceptions])
@pytest.mark.parametrize("module", [cdpify, error])
@pytest.mark.parametrize(
("old_name", "new_name"),
[
Expand All @@ -48,7 +48,7 @@ def test_old_exception_names_are_deprecated_aliases(
with pytest.deprecated_call(match=new_name):
alias = getattr(module, old_name)

assert alias is getattr(exceptions, new_name)
assert alias is getattr(error, new_name)


_IMPLEMENTATIONS = pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_event_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import pytest

from cdpify.codec import decode_cdp
from cdpify.error import CDPStreamClosedError
from cdpify.events import EventRouter
from cdpify.exceptions import CDPStreamClosedError
from cdpify.transport import TransportEvent


Expand Down
2 changes: 1 addition & 1 deletion tests/test_websocket_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from websockets.exceptions import ConnectionClosedOK

from cdpify import CdpClient
from cdpify.exceptions import CDPConnectionError, CDPStreamClosedError
from cdpify.error import CDPConnectionError, CDPStreamClosedError
from cdpify.transports import websocket as websocket_module


Expand Down
2 changes: 1 addition & 1 deletion tests/test_websocket_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
from websockets.exceptions import ConnectionClosedOK

from cdpify.exceptions import (
from cdpify.error import (
CDPCommandError,
CDPConnectionError,
CDPTimeoutError,
Expand Down
Loading