Can't use a subscripted `ThingSlot`
Maintainers usually reply within 3 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 55/100
Research direction
Start by reading the ThingSlot and BaseDescriptor definitions and the code that handles __orig_class__; the issue identifies the mismatch between the one-parameter subscription and the descriptor’s two type parameters. Check existing tests for thing_slot() and descriptor typing behavior. Done means ThingSlot[MyOtherThing]() works as expected or the supported behavior is documented clearly.
Written by the indexing model from the issue text.
Description
Describe the bug
The public API says I should define a Thing Slot like:
class MyThing(lt.Thing):
other_thing: MyOtherThing = lt.thing_slot()
This works fine.
I expected I could also do this:
class MyThing(lt.Thing):
other_thing = ThingSlot[MyOtherThing]()
The second form (which isn't recommended anywhere) does not work. The reason for this is that BaseDescriptor expects two type parameters, the first is the host class and the second is the value. When it calls __orig_class__, it gets ThingSlot[ValueType] and not BaseDescriptor[lt.Thing, ValueType].
To Reproduce
Define a ThingSlot using the type in a subscript, as shown above.
Expected behaviour
I hoped the two examples above would be equivalent.
Additional context
The subscripted form is not really used or recommended anywhere. We could just remove it - but I feel like it has its uses. This isn't blocking anything, so it's likely to sit in the backlog for a little while.
- Dominant language
- Python
- Stars
- 10
- Forks
- 4
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 11
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from labthings/labthings-fastapi
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
labthings/labthings-fastapi#438 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
labthings/labthings-fastapi#435 ·
Maintainers usually reply within 3 days
-
Consider atomic JSON writesMay be free again @ashiishe2-oss claimed this 26 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
labthings/labthings-fastapi#412 · 3 comments ·
Maintainers usually reply within 3 days
-
drop-python-version
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
labthings/labthings-fastapi#354 · 2 comments ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
labthings/labthings-fastapi#312 · 1 comment ·
Maintainers usually reply within 3 days
All issues in labthings/labthings-fastapi
Similar issues
-
bug feature request
Difficulty 2/5 1-3 hours Newbie friendliness 67/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Qiskit/qiskit-obp#156 ·
-
action-item enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
getcommunityone/open-navigator#1658 ·
Maintainers usually reply within 1 day
-
review-panel severity:low
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
kristovatlas/coin-accounting#636 ·
Maintainers usually reply within 1 day