Skip to content

Commit

Permalink
Mark all packets as final
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsDrike committed Mar 1, 2023
1 parent e2c24ae commit d7d8277
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
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

0 comments on commit d7d8277

Please sign in to comment.