Skip to content

Use slots=True on all dataclasses. #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions htpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _attrs_string(attrs: Mapping[str, Attribute]) -> str:
P = t.ParamSpec("P")


@dataclasses.dataclass(frozen=True)
@dataclasses.dataclass(frozen=True, slots=True)
class ContextProvider(t.Generic[T]):
context: Context[T]
value: T
Expand All @@ -154,7 +154,7 @@ def encode(self, encoding: str = "utf-8", errors: str = "strict") -> bytes:
return str(self).encode(encoding, errors)


@dataclasses.dataclass(frozen=True)
@dataclasses.dataclass(frozen=True, slots=True)
class ContextConsumer(t.Generic[T]):
context: Context[T]
debug_name: str
Expand Down Expand Up @@ -183,7 +183,7 @@ class _NO_DEFAULT:
pass


@dataclasses.dataclass(frozen=True)
@dataclasses.dataclass(frozen=True, slots=True)
class Context(t.Generic[T]):
name: str
_: dataclasses.KW_ONLY
Expand Down
Empty file added t.py
Empty file.
2 changes: 1 addition & 1 deletion tests/test_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from .conftest import RenderFixture

letter_ctx: Context[t.Literal["a", "b", "c"]] = Context("letter", default="a")
no_default_ctx = Context[str]("no_default")
no_default_ctx: Context[str] = Context("no_default")


@letter_ctx.consumer
Expand Down