Skip to content

Commit edbcb7d

Browse files
committed
Adjust MtaMilterSession attributes to pass mypy 1.5.0
Observed before this change with mypy==1.5.0: error: Trying to assign name "[...]" that is not in "__slots__" of type "purepythonmilter.server.session.MtaMilterSession" [misc] Mypy gained this feature to learn __slots__ for dataclasses (here via attrs classes) in python/mypy#15649.
1 parent fe84364 commit edbcb7d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/purepythonmilter/server/session.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,21 @@ class MtaMilterSession(AbstractMtaMilterSession):
5555
macros_per_stage: dict[definitions.MacroStage, dict[str, str]] = attrs.field(
5656
init=False, factory=dict
5757
)
58-
_last_macro_command: commands.DefineMacro | None = None
58+
_last_macro_command: commands.DefineMacro | None = attrs.field(
59+
init=False, default=None
60+
)
5961
all_macros: dict[str, str] = attrs.field(init=False, factory=dict)
6062
queue_reader_timeout_seconds: float = attrs.field(
6163
default=QUEUE_READER_TIMEOUT_SECONDS_DEFAULT
6264
)
6365
_pending_manipulations: list[responses.AbstractManipulation] = attrs.field(
6466
init=False, factory=list
6567
)
66-
_manipulations_sent: bool = False
68+
_manipulations_sent: bool = attrs.field(init=False, default=False)
69+
_closed: bool = attrs.field(init=False, default=False)
70+
logger: logging.LoggerAdapter[logging.Logger] = attrs.field(init=False)
6771

6872
def __attrs_post_init__(self) -> None:
69-
self._closed = False
7073
self.logger = logger.ConnectionContextLogger().get(__name__)
7174
self._app = self._socket_connection.app_factory(session=self)
7275
self.logger.debug("Starting commands_consumer task")

0 commit comments

Comments
 (0)