Skip to content

Commit c8bb9bf

Browse files
authored
Set slots_default for better ty support (#1649)
1 parent ee66e72 commit c8bb9bf

3 files changed

Lines changed: 53 additions & 43 deletions

File tree

‎pyproject.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ dev = [
8787
exclude-newer = "1 week"
8888

8989
[tool.uv.exclude-newer-package]
90-
pyrefly = false # need pyrefly 1.2.0; remove after 2026-08-07
9190

9291

9392
[tool.hatch.version]

‎src/attrs/__init__.pyi‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ def field(
159159
type: type | None = ...,
160160
) -> Any: ...
161161
@overload
162-
@dataclass_transform(field_specifiers=(attrib, field))
162+
@dataclass_transform( # type: ignore[misc]
163+
field_specifiers=(attrib, field),
164+
slots_default=True, # only supported by ty
165+
)
163166
def define(
164167
maybe_cls: _C,
165168
*,
@@ -185,7 +188,10 @@ def define(
185188
match_args: bool = ...,
186189
) -> _C: ...
187190
@overload
188-
@dataclass_transform(field_specifiers=(attrib, field))
191+
@dataclass_transform( # type: ignore[misc]
192+
field_specifiers=(attrib, field),
193+
slots_default=True, # only supported by ty
194+
)
189195
def define(
190196
maybe_cls: None = ...,
191197
*,
@@ -214,7 +220,11 @@ def define(
214220
mutable = define
215221

216222
@overload
217-
@dataclass_transform(frozen_default=True, field_specifiers=(attrib, field))
223+
@dataclass_transform( # type: ignore[misc]
224+
frozen_default=True,
225+
field_specifiers=(attrib, field),
226+
slots_default=True, # only supported by ty
227+
)
218228
def frozen(
219229
maybe_cls: _C,
220230
*,
@@ -240,7 +250,11 @@ def frozen(
240250
match_args: bool = ...,
241251
) -> _C: ...
242252
@overload
243-
@dataclass_transform(frozen_default=True, field_specifiers=(attrib, field))
253+
@dataclass_transform( # type: ignore[misc]
254+
frozen_default=True,
255+
field_specifiers=(attrib, field),
256+
slots_default=True, # only supported by ty
257+
)
244258
def frozen(
245259
maybe_cls: None = ...,
246260
*,

0 commit comments

Comments
 (0)