You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Class-level `kw_only=True` behavior is now consistent with `dataclasses`.
2
2
3
-
Previously, a class that sets `kw_only=True` makes all attributes keyword-only,
4
-
including those from base classes. If an attribute sets `kw_only=False`, that
5
-
setting is ignored, and it is still made keyword-only.
3
+
Previously, a class that sets `kw_only=True` makes all attributes keyword-only, including those from base classes.
4
+
If an attribute sets `kw_only=False`, that setting is ignored, and it is still made keyword-only.
6
5
7
-
Now, only the attributes defined in that class that doesn't explicitly set
8
-
`kw_only=False` are made keyword-only.
6
+
Now, only the attributes defined in that class that doesn't explicitly set `kw_only=False` are made keyword-only.
9
7
10
8
This shouldn't be a problem for most users, unless you have a pattern like this:
11
9
@@ -20,9 +18,5 @@ class Subclass(Base):
20
18
c: int
21
19
```
22
20
23
-
Here, we have a `kw_only=True` attrs class (`Base`) with an attribute that sets
24
-
`kw_only=False` and has a default (`Base.b`), and then create a subclass (`Subclass`)
25
-
with required arguments (`Subclass.c`). Previously this would work, since it
26
-
would make `Base.b` keyword-only, but now this fails since `Base.b` is positional, and
27
-
we have a required positional argument (`Subclass.c`) following another argument with
28
-
defaults.
21
+
Here, we have a `kw_only=True`*attrs* class (`Base`) with an attribute that sets `kw_only=False` and has a default (`Base.b`), and then create a subclass (`Subclass`) with required arguments (`Subclass.c`).
22
+
Previously this would work, since it would make `Base.b` keyword-only, but now this fails since `Base.b` is positional, and we have a required positional argument (`Subclass.c`) following another argument with defaults.
0 commit comments