Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark all packets as final #53

Merged
merged 1 commit into from
Mar 1, 2023
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
1 change: 1 addition & 0 deletions changes/53.internal.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Mark all packet classes as `typing.final`, making the type-checker enforce existence of concrete implementations for all abstract methods.
3 changes: 2 additions & 1 deletion mcproto/packets/v757/handshaking/handshake.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from enum import IntEnum
from typing import ClassVar, Union
from typing import ClassVar, Union, final

from typing_extensions import Self

Expand All @@ -20,6 +20,7 @@ class NextState(IntEnum):
LOGIN = 2


@final
class Handshake(ServerBoundPacket):
"""Initializes connection between server and client. (Client -> Server)"""

Expand Down
3 changes: 2 additions & 1 deletion mcproto/packets/v757/status/ping.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import ClassVar
from typing import ClassVar, final

from typing_extensions import Self

Expand All @@ -11,6 +11,7 @@
__all__ = ["PingPong"]


@final
class PingPong(ClientBoundPacket, ServerBoundPacket):
"""Ping request/Pong response (Server <-> Client)."""

Expand Down
4 changes: 3 additions & 1 deletion mcproto/packets/v757/status/status.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import json
from typing import Any, ClassVar
from typing import Any, ClassVar, final

from typing_extensions import Self

Expand All @@ -11,6 +11,7 @@
__all__ = ["StatusRequest", "StatusResponse"]


@final
class StatusRequest(ServerBoundPacket):
"""Request from the client to get information on the server. (Client -> Server)"""

Expand All @@ -27,6 +28,7 @@ def deserialize(cls, buf: Buffer, /) -> Self: # pragma: no cover, nothing to te
return cls()


@final
class StatusResponse(ClientBoundPacket):
"""Response from the server to requesting client with status data information. (Server -> Client)"""

Expand Down