-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
493 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
import abc | ||
from io import BytesIO | ||
from typing import Generic, TypeVar | ||
|
||
T = TypeVar("T") | ||
|
||
class AbstractType(metaclass=abc.ABCMeta): | ||
|
||
class AbstractType(Generic[T], metaclass=abc.ABCMeta): | ||
@classmethod | ||
@abc.abstractmethod | ||
def encode(cls, value): ... | ||
def encode(cls, value: T) -> bytes: ... | ||
|
||
@classmethod | ||
@abc.abstractmethod | ||
def decode(cls, data): ... | ||
def decode(cls, data: BytesIO) -> T: ... | ||
|
||
@classmethod | ||
def repr(cls, value): | ||
def repr(cls, value: T) -> str: | ||
return repr(value) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.