Skip to content

Commit

Permalink
Improve typing in various places
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsDrike committed Jan 6, 2025
1 parent f87442e commit a6a6982
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
4 changes: 3 additions & 1 deletion mcstatus/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,16 @@ class Address(_AddressBase):
The class is not a part of a Public API, but attributes :attr:`host` and :attr:`port` are a part of Public API.
"""

def __init__(self, *a, **kw):
def __init__(self, host: str, port: int):
# We don't call super's __init__, because NamedTuples handle everything
# from __new__ and the passed self already has all of the parameters set.
self._cached_ip: ipaddress.IPv4Address | ipaddress.IPv6Address | None = None

# Make sure the address is valid
self._ensure_validity(self.host, self.port)

super().__init__(host, port)

@staticmethod
def _ensure_validity(host: object, port: object) -> None:
if not isinstance(host, str):
Expand Down
2 changes: 1 addition & 1 deletion mcstatus/forge_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def decode(cls, buffer: Connection) -> tuple[Self, list[ForgeDataChannel]]:
if not is_server:
mod_version = buffer.read_utf()

channels = []
channels: list[ForgeDataChannel] = []
for _ in range(channel_count):
channels.append(ForgeDataChannel.decode(buffer, mod_id))

Expand Down
2 changes: 1 addition & 1 deletion mcstatus/motd/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class HtmlTransformer(PlainTransformer):

def __init__(self, *, bedrock: bool = False) -> None:
self.bedrock = bedrock
self.on_reset = []
self.on_reset: list[str] = []

def transform(self, motd_components: Sequence[ParsedMotdComponent]) -> str:
self.on_reset = []
Expand Down
1 change: 0 additions & 1 deletion mcstatus/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ def decorate(obj: Callable[P, R] | type[T]) -> Callable[P, R] | type[T]:
return obj

# Regular function deprecation
obj = cast("Callable[P, R]", obj)
if methods is not None:
raise ValueError("Methods can only be specified when decorating a class, not a function")
return decorate_func(obj, warn_message)
Expand Down

0 comments on commit a6a6982

Please sign in to comment.