From 3203360d5abf5d645429259fa87270965e8786dc Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Fri, 27 Mar 2026 09:16:58 +0100 Subject: [PATCH 1/4] docs: use modern field API in 'boilerplate' section. --- docs/how-does-it-work.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/how-does-it-work.md b/docs/how-does-it-work.md index 96dc5c303..6e07e69f5 100644 --- a/docs/how-does-it-work.md +++ b/docs/how-does-it-work.md @@ -7,8 +7,8 @@ *attrs* isn't the first library that aims to simplify class definition in Python. But its **declarative** approach combined with **no runtime overhead** lets it stand out. -Once you apply the `@attrs.define` (or `@attr.s`) decorator to a class, *attrs* searches the class object for instances of `attr.ib`s. -Internally they're a representation of the data passed into `attr.ib` along with a counter to preserve the order of the attributes. +Once you apply the `@attrs.define` (or `@attr.s`) decorator to a class, *attrs* searches the class object for instances of `attrs.field`s. +Internally they're a representation of the data passed into `field` along with a counter to preserve the order of the attributes. Alternatively, it's possible to define them using {doc}`types`. In order to ensure that subclassing works as you'd expect it to work, *attrs* also walks the class hierarchy and collects the attributes of all base classes. From 3f891cfca9c58a293795677d4e840dcac3fa5979 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Fri, 27 Mar 2026 09:32:38 +0100 Subject: [PATCH 2/4] Adjust for review comment --- docs/how-does-it-work.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/how-does-it-work.md b/docs/how-does-it-work.md index 6e07e69f5..e1b9772e2 100644 --- a/docs/how-does-it-work.md +++ b/docs/how-does-it-work.md @@ -7,9 +7,8 @@ *attrs* isn't the first library that aims to simplify class definition in Python. But its **declarative** approach combined with **no runtime overhead** lets it stand out. -Once you apply the `@attrs.define` (or `@attr.s`) decorator to a class, *attrs* searches the class object for instances of `attrs.field`s. +Once you apply the `@attrs.define` (or `@attr.s`) decorator to a class, *attrs* searches the class object for {doc}`types` and instances of `attrs.field`s. Internally they're a representation of the data passed into `field` along with a counter to preserve the order of the attributes. -Alternatively, it's possible to define them using {doc}`types`. In order to ensure that subclassing works as you'd expect it to work, *attrs* also walks the class hierarchy and collects the attributes of all base classes. Please note that *attrs* does *not* call `super()` *ever*. From 162a1093ae9d09ce37c10659c1c82906be3577c8 Mon Sep 17 00:00:00 2001 From: Carlton Gibson Date: Fri, 27 Mar 2026 11:11:09 +0100 Subject: [PATCH 3/4] Tweak to second sentence. --- docs/how-does-it-work.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/how-does-it-work.md b/docs/how-does-it-work.md index e1b9772e2..577597134 100644 --- a/docs/how-does-it-work.md +++ b/docs/how-does-it-work.md @@ -8,7 +8,7 @@ But its **declarative** approach combined with **no runtime overhead** lets it stand out. Once you apply the `@attrs.define` (or `@attr.s`) decorator to a class, *attrs* searches the class object for {doc}`types` and instances of `attrs.field`s. -Internally they're a representation of the data passed into `field` along with a counter to preserve the order of the attributes. +Internally `field`s are a representation of the data passed, along with a counter to preserve the order of the attributes. In order to ensure that subclassing works as you'd expect it to work, *attrs* also walks the class hierarchy and collects the attributes of all base classes. Please note that *attrs* does *not* call `super()` *ever*. From 4195388270b9e570fce592198237175e3ab520fe Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Fri, 27 Mar 2026 11:11:58 +0100 Subject: [PATCH 4/4] Apply suggestion from @hynek --- docs/how-does-it-work.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/how-does-it-work.md b/docs/how-does-it-work.md index 577597134..c458ba7e8 100644 --- a/docs/how-does-it-work.md +++ b/docs/how-does-it-work.md @@ -7,7 +7,7 @@ *attrs* isn't the first library that aims to simplify class definition in Python. But its **declarative** approach combined with **no runtime overhead** lets it stand out. -Once you apply the `@attrs.define` (or `@attr.s`) decorator to a class, *attrs* searches the class object for {doc}`types` and instances of `attrs.field`s. +Once you apply the `@attrs.define` (or `@attr.s`) decorator to a class, *attrs* searches the class object for type hints and instances of `attrs.field`s. Internally `field`s are a representation of the data passed, along with a counter to preserve the order of the attributes. In order to ensure that subclassing works as you'd expect it to work, *attrs* also walks the class hierarchy and collects the attributes of all base classes.