Skip to content

Commit 3e67afb

Browse files
authored
Merge branch 'main' into uv-lock
2 parents 4424852 + 55c688a commit 3e67afb

10 files changed

Lines changed: 47 additions & 8 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ ci:
44

55
repos:
66
- repo: https://github.com/astral-sh/ruff-pre-commit
7-
rev: v0.9.9
7+
rev: v0.11.4
88
hooks:
99
- id: ruff
1010
args: [--fix, --exit-non-zero-on-fix]

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,28 @@ Changes for the upcoming release can be found in the [`changelog.d` directory](h
1212

1313
<!-- towncrier release notes start -->
1414

15+
## [25.3.0](https://github.com/python-attrs/attrs/tree/25.3.0) - 2025-03-13
16+
17+
### Changes
18+
19+
- Restore support for generator-based `field_transformer`s.
20+
[#1417](https://github.com/python-attrs/attrs/issues/1417)
21+
22+
23+
## [25.2.0](https://github.com/python-attrs/attrs/tree/25.2.0) - 2025-03-12
24+
25+
### Changes
26+
27+
- Checking mandatory vs non-mandatory attribute order is now performed after the field transformer, since the field transformer may change attributes and/or their order.
28+
[#1147](https://github.com/python-attrs/attrs/issues/1147)
29+
- `attrs.make_class()` now allows for Unicode class names.
30+
[#1406](https://github.com/python-attrs/attrs/issues/1406)
31+
- Speed up class creation by 30%-50% by compiling methods only once and using a variety of other techniques.
32+
[#1407](https://github.com/python-attrs/attrs/issues/1407)
33+
- The error message if an attribute has both an annotation and a type argument will now disclose _what_ attribute seems to be the problem.
34+
[#1410](https://github.com/python-attrs/attrs/issues/1410)
35+
36+
1537
## [25.1.0](https://github.com/python-attrs/attrs/tree/25.1.0) - 2025-01-25
1638

1739
### Changes

changelog.d/1147.change.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog.d/1406.change.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

changelog.d/1407.change.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/conf.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
"https://github.com/python-attrs/attrs/tree/.*",
3535
]
3636

37+
linkcheck_anchors_ignore_for_url = [
38+
r"^https?://(www\.)?github\.com/.*",
39+
]
40+
3741
# In nitpick mode (-n), still ignore any of the following "broken" references
3842
# to non-types.
3943
nitpick_ignore = [

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-License-Identifier: MITpyp
1+
# SPDX-License-Identifier: MIT
22

33
[build-system]
44
requires = ["hatchling", "hatch-vcs", "hatch-fancy-pypi-readme>=23.2.0"]

src/attr/_make.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def _transform_attrs(
448448
attrs = base_attrs + own_attrs
449449

450450
if field_transformer is not None:
451-
attrs = field_transformer(cls, attrs)
451+
attrs = tuple(field_transformer(cls, attrs))
452452

453453
# Check attr order after executing the field_transformer.
454454
# Mandatory vs non-mandatory attr order only matters when they are part of
@@ -2491,7 +2491,7 @@ def from_counting_attr(cls, name: str, ca: _CountingAttr, type=None):
24912491
if type is None:
24922492
type = ca.type
24932493
elif ca.type is not None:
2494-
msg = "Type annotation and type argument cannot both be present"
2494+
msg = f"Type annotation and type argument cannot both be present for '{name}'."
24952495
raise ValueError(msg)
24962496
return cls(
24972497
name,

tests/test_annotations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class C:
6262
x: int = attr.ib(type=int)
6363

6464
assert (
65-
"Type annotation and type argument cannot both be present",
65+
"Type annotation and type argument cannot both be present for 'x'.",
6666
) == e.value.args
6767

6868
def test_typing_annotations(self):

tests/test_hooks.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,22 @@ class C:
217217
assert "CAttributes" == fields_type.__name__
218218
assert issubclass(fields_type, tuple)
219219

220+
def test_hook_generator(self):
221+
"""
222+
field_transfromers can be a generators.
223+
224+
Regression test for #1416.
225+
"""
226+
227+
def hook(cls, attribs):
228+
yield from attribs
229+
230+
@attr.s(auto_attribs=True, field_transformer=hook)
231+
class Base:
232+
x: int
233+
234+
assert ["x"] == [a.name for a in attr.fields(Base)]
235+
220236

221237
class TestAsDictHook:
222238
def test_asdict(self):

0 commit comments

Comments
 (0)