labthings / labthings/labthings-fastapi
Incorrect types in for `Invocation.action`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 9
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
In the OpenFlexure microscope server we use the ActionManager of the server to determine the calling action for an invocation when recording log information. We get the invocation with get_invocation(). Using this Invocation object we can do invocation.action.name to get the action name. But MyPy throws and error unless you call invocation.action().name; this makes MyPy happy but throws an error at runtime. The issues seems to be because the action is a descriptor.
To get around this we directly invocation.action_ref().name which even though there is no leading underscore feels like accessing an internal.
To Reproduce
- On an
Invocationobject add the lineinvocation.action.name - Run MyPy
Expected behaviour
MyPy passes as the code is fine
Actual behaviour
MyPy throws and error unless you do invocation.action().name. This errors at runtime.
System:
- OS: Kuuntu 24.04 (verified also on docker image python:3.11)
- Python version: 3.11
- Version: 0.3.0
Contributor 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.
Research direction
Start with the Invocation and ActionManager implementations, especially get_invocation(), action, and action_ref(), then reproduce the issue by checking invocation.action.name with MyPy. Done means the public invocation.action.name usage passes MyPy and works at runtime without requiring the internal-looking action_ref().
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fastapi, python
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 63/100