Skip to content

Commit 4dd2699

Browse files
committed
Tweak keyword-only definition of AttributeIORef
This gives a nice reference of how to add KW_ONLY to the fields of child classes so that they can have non-default fields, including positional fields. Functionally it is the same.
1 parent 71e1a2e commit 4dd2699

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/fastcs/attribute_io_ref.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
from dataclasses import dataclass
1+
from dataclasses import KW_ONLY, dataclass
22

33
from typing_extensions import TypeVar
44

55

6-
@dataclass(kw_only=True)
6+
@dataclass
77
class AttributeIORef:
88
"""Base for references to define IO for an ``Attribute`` over an API.
99
@@ -14,6 +14,8 @@ class AttributeIORef:
1414
server.
1515
"""
1616

17+
# Make fields keyword-only so that child classes can have fields without defaults
18+
_: KW_ONLY
1719
update_period: float | None = None
1820

1921

0 commit comments

Comments
 (0)