Commit b1d12a9e authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Explicitly define argument types of unexpected message exceptions

parent 2ba6872f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -271,7 +271,7 @@ class FilterProtocol:
		if message.ident in UPDATE_RESPONSES and isinstance(event, messages.EndOfMessage):
			return
		if message.ident not in responses:
			raise InvalidMessage(event, message)
			raise InvalidMessage(message, event)
		self.state = None

	def _store_mta_flags(self, message: messages.Negotiate) -> None:
+9 −0
Original line number Diff line number Diff line
@@ -10,6 +10,9 @@ Exceptions raised by the package

from typing import TYPE_CHECKING

if TYPE_CHECKING:
	from .messages import Message

__all__ = [
	"InsufficientSpace", "NeedsMore", "UnexpectedMessage", "InvalidMessage",
	"UnknownMessage",
@@ -58,6 +61,9 @@ class UnexpectedMessage(TypeError):
	Raised by a protocol to indicate a message that is not expected in the current state
	"""

	if TYPE_CHECKING:
		def __init__(self, message: Message): ...

	def __str__(self) -> str:
		return f"message was not expected by the protocol: {self.args[0]}"

@@ -66,3 +72,6 @@ class InvalidMessage(UnexpectedMessage):
	"""
	Raised by a protocol to indicate a message that is unknown to the state machine
	"""

	if TYPE_CHECKING:
		def __init__(self, message: Message, event: Message|None = None): ...