Use _ReadableStream from codecs (#13167)

This commit is contained in:
Konstantin Baikov
2024-12-03 09:04:28 +01:00
committed by GitHub
parent cb15f9e832
commit 9d743a3f1e

View File

@@ -1,5 +1,6 @@
from codecs import _ReadableStream, _WritableStream
from collections.abc import Callable, Mapping, Sequence
from typing import Any, ClassVar, Literal, Protocol
from typing import Any, ClassVar, Literal
from typing_extensions import Self
from xml.etree.ElementTree import Element
@@ -7,18 +8,6 @@ from . import blockparser, inlinepatterns, postprocessors, preprocessors, treepr
from .extensions import Extension
from .util import HtmlStash, Registry
# TODO: The following protocols can be replaced by their counterparts from
# codecs, once they have been propagated to all type checkers.
class _WritableStream(Protocol):
def write(self, data: bytes, /) -> object: ...
def seek(self, offset: int, whence: int, /) -> object: ...
def close(self) -> object: ...
class _ReadableStream(Protocol):
def read(self, size: int = ..., /) -> bytes: ...
def seek(self, offset: int, whence: int, /) -> object: ...
def close(self) -> object: ...
class Markdown:
preprocessors: Registry[preprocessors.Preprocessor]
inlinePatterns: Registry[inlinepatterns.Pattern]