DiamondLightSource / DiamondLightSource/httomo
Update `MonitoringInterface.write_results()` to use an IO protocol rather than `typing.TextIO`
- Dominant language
- Python
- Stars
- 10
- Forks
- 5
- Avg merge
- 5d 17h
- Merged PRs (30d)
- 1
Description
Related to the `dest` parameter (type-hinted as `typing.TextIO`) of the `write_results()` method described in the protocol `MonitoringInterface` in #214
In the unlikely event of an error during writing, it'd be nice to be able to clean up stuff related to the resource that was being written to, which naturally begs the question of possibly using `with` on the `dest` parameter in implementations of the `write_results()` method.
Taking a quick look at stuff online about `typing.TextIO` to see if it specifically referred to objects that implement the protocol to be a [context manager](https://peps.python.org/pep-0343/), [this discussion](https://github.com/python/typing/discussions/829) in the python `typing` repo was found. It seems like the preferred direction would be to use a protocol rather than something from the `typing` module. Using such a protocol I think would then guarantee the behaviour to be used as a context manager, and would then allow the use of `with` in the `write_results()` method in `MonitoringInterface`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.