Skip to content

Commit 9c890be

Browse files
committed
docs: resolve the UnboundGetter references the declare overloads emit
The docs job failed with four nitpicky warnings, all of them the `UnboundGetter` in an `AttrR.declare`/`AttrRW.declare` overload. Two of them were a real problem: the alias was defined in `attr_decorator.py` and imported into `attr_r.py`/`attr_rw.py` only under `TYPE_CHECKING`, so sphinx could not evaluate the annotation and fell back to a bare, unresolvable name. `UnboundGetter` now lives in `attr_r.py` next to `Getter`, and `UnboundSetter` in `attr_w.py` next to `Setter`, which is where they belong and removes an import cycle rather than working around one; `attr_decorator.py` imports them. The other two are nested inside the `Callable[...]` the parameterised overload returns, where a type alias cannot answer the `py:class` reference sphinx emits, so they get a `nitpick_ignore` entry saying so. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JAWLNMnpQSJKbsZXa3NDZx
1 parent 45f0db2 commit 9c890be

6 files changed

Lines changed: 25 additions & 13 deletions

File tree

docs/conf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@
107107
# A ParamSpec gets no target of its own, so `Command[P, T]` renders a
108108
# reference to a bare `P` that resolves to nothing
109109
("py:class", "P"),
110+
# `UnboundGetter` resolves where it is a parameter's own annotation, but
111+
# not where it is nested inside the `Callable[...]` an `AttrR.declare` /
112+
# `AttrRW.declare` overload returns: a type alias is a `py:data` target,
113+
# and a nested argument is rendered as a `py:class` reference
114+
("py:class", "UnboundGetter"),
110115
]
111116
nitpick_ignore_regex = [
112117
("py:class", r"fastcs.*.DType_T"),

src/fastcs/attributes/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
from .attr_decorator import AttrSetter as AttrSetter
22
from .attr_decorator import UnboundAttr as UnboundAttr
33
from .attr_decorator import UnboundAttrRW as UnboundAttrRW
4-
from .attr_decorator import UnboundGetter as UnboundGetter
5-
from .attr_decorator import UnboundSetter as UnboundSetter
64
from .attr_r import AttrR as AttrR
75
from .attr_r import Getter as Getter
86
from .attr_r import NotPolled as NotPolled
97
from .attr_r import Polled as Polled
108
from .attr_r import Schedule as Schedule
9+
from .attr_r import UnboundGetter as UnboundGetter
1110
from .attr_rw import AttrRW as AttrRW
1211
from .attr_w import AttrW as AttrW
1312
from .attr_w import Setter as Setter
13+
from .attr_w import UnboundSetter as UnboundSetter
1414
from .attribute import Attribute as Attribute
1515
from .attribute import AttributeAccessMode as AttributeAccessMode
1616
from .hinted_attribute import HintedAttribute as HintedAttribute

src/fastcs/attributes/attr_decorator.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,19 @@ async def set_voltage(self, value: float) -> None:
4444
_datatype_for_annotation,
4545
_unwrap_update_annotation,
4646
)
47-
from fastcs.attributes.attr_r import AttrR, NotPolled, Polled, Schedule
47+
from fastcs.attributes.attr_r import (
48+
AttrR,
49+
NotPolled,
50+
Polled,
51+
Schedule,
52+
UnboundGetter,
53+
)
4854
from fastcs.attributes.attr_rw import AttrRW
55+
from fastcs.attributes.attr_w import UnboundSetter
4956
from fastcs.attributes.update import Update
5057
from fastcs.datatypes import DType_T, Meta
5158
from fastcs.util import Controller_T
5259

53-
UnboundGetter = Callable[[Controller_T], Awaitable[DType_T | Update[DType_T]]]
54-
"""A declared getter, taking the `Controller` it will be bound to as ``self``"""
55-
UnboundSetter = Callable[
56-
[Controller_T, DType_T], Awaitable[None | DType_T | Update[DType_T]]
57-
]
58-
"""An ``@x.setter`` setter, taking the `Controller` it will be bound to as ``self``"""
59-
6060

6161
def _type_name(datatype: Any) -> str:
6262
"""A datatype as it was most likely written, to name it in an error."""

src/fastcs/attributes/attr_r.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@
3131
from fastcs.util import ONCE, Controller_T
3232

3333
if TYPE_CHECKING:
34-
from fastcs.attributes.attr_decorator import UnboundAttr, UnboundGetter
34+
from fastcs.attributes.attr_decorator import UnboundAttr
3535

3636
Getter = Callable[[], Awaitable[DType_T | Update[DType_T]]]
3737
"""A callable that fetches a fresh value for an attribute from its source"""
38+
UnboundGetter = Callable[[Controller_T], Awaitable[DType_T | Update[DType_T]]]
39+
"""A declared getter, taking the `Controller` it will be bound to as ``self``"""
3840
AttrReadbackCallback = Callable[[DType_T], Coroutine[None, None, None]]
3941
"""A callback to be called when the readback of the attribute updates"""
4042

src/fastcs/attributes/attr_rw.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from collections.abc import Callable
44
from typing import TYPE_CHECKING, Any, Unpack, overload
55

6-
from fastcs.attributes.attr_r import AttrR, Getter, Schedule
6+
from fastcs.attributes.attr_r import AttrR, Getter, Schedule, UnboundGetter
77
from fastcs.attributes.attr_w import AttrW, Setter
88
from fastcs.attributes.attribute import AttributeAccessMode
99
from fastcs.attributes.update import Update
@@ -27,7 +27,7 @@
2727
from fastcs.util import Controller_T
2828

2929
if TYPE_CHECKING:
30-
from fastcs.attributes.attr_decorator import UnboundAttrRW, UnboundGetter
30+
from fastcs.attributes.attr_decorator import UnboundAttrRW
3131

3232

3333
class AttrRW(AttrR[DType_T], AttrW[DType_T]):

src/fastcs/attributes/attr_w.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,14 @@
2323
TableMeta,
2424
)
2525
from fastcs.logging import logger
26+
from fastcs.util import Controller_T
2627

2728
Setter = Callable[[DType_T], Awaitable[None | DType_T | Update[DType_T]]]
2829
"""A callable that applies a new setpoint to an attribute's source"""
30+
UnboundSetter = Callable[
31+
[Controller_T, DType_T], Awaitable[None | DType_T | Update[DType_T]]
32+
]
33+
"""An ``@x.setter`` setter, taking the `Controller` it will be bound to as ``self``"""
2934
AttrSetpointCallback = Callable[[DType_T], Coroutine[None, None, None]]
3035
"""A callback to be called when the setpoint of the attribute updates"""
3136

0 commit comments

Comments
 (0)