~nhanb/mcross

0265fd4c7f50a6fff0f10fe61e4998df3a225023 — Bùi Thành Nhân 1 year, 4 months ago f3bda5d curio 0.5.5
use slots
3 files changed, 4 insertions(+), 5 deletions(-)

M pyproject.toml
M src/mcross/document.py
M src/mcross/transport.py
M pyproject.toml => pyproject.toml +1 -1
@@ 1,6 1,6 @@
[tool.poetry]
name = "mcross"
version = "0.5.4"
version = "0.5.5"
description = "Do you remember www?"
authors = ["nhanb <hi@imnhan.com>"]
license = "MIT"

M src/mcross/document.py => src/mcross/document.py +2 -0
@@ 6,6 6,7 @@ HEADING_LINE_PATTERN = re.compile(r"^(#{1,3})\s+(.+)$")


class GeminiNode:
    __slots__ = ("text",)
    text: str

    def __init__(self, text):


@@ 36,6 37,7 @@ class H3Node(GeminiNode):


class LinkNode(GeminiNode):
    __slots__ = ("url", "name")
    url: str
    name: str


M src/mcross/transport.py => src/mcross/transport.py +1 -4
@@ 8,10 8,6 @@ MAX_RESP_BODY_BYTES = 1024 * 1024 * 5
MAX_REDIRECTS = 3


# Wanted to use a dataclass here but ofc it doesn't allow a slotted class to
# have fields with default values:
# https://stackoverflow.com/questions/50180735/how-can-dataclasses-be-made-to-work-better-with-slots
# Maaaaybe I should just use attrs and call it a day.
class Response:
    __slots__ = ("status", "meta", "body", "url")



@@ 47,6 43,7 @@ class NonAbsoluteUrlWithoutContextError(Exception):

class GeminiUrl:
    PROTOCOL = "gemini"
    __slots__ = ("host", "port", "path")
    host: str
    port: int
    path: str