Skip to content

Use abstract classes for base classes in protocol package #459

@PerchunPak

Description

@PerchunPak

class BaseConnection:
"""Base Connection class. Implements flush, receive, and remaining."""
__slots__ = ()
def __repr__(self) -> str:
"""Return representation of self."""
return f"<{self.__class__.__name__} Object>"
def flush(self) -> bytearray:
"""Raise TypeError, unsupported."""
raise TypeError(f"{self.__class__.__name__} does not support flush()")
def receive(self, data: BytesConvertable | bytearray) -> None:
"""Raise TypeError, unsupported."""
raise TypeError(f"{self.__class__.__name__} does not support receive()")
def remaining(self) -> int:
"""Raise TypeError, unsupported."""
raise TypeError(f"{self.__class__.__name__} does not support remaining()")

This class only adds methods, that just raise exception. We should use abstract class here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: apiRelated to exposed core API of the projectt: enhancementImprovement to an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions