DiamondLightSource / DiamondLightSource/httomo

Incorrect type-hint in UI layer's `check_valid_ref_id()` function

Open
#474 0 comments 0 reactions 0 assignees View on GitHub
minor refactor
Dominant language
Python
Stars
10
Forks
5
Avg merge
5d 17h
Merged PRs (30d)
1

Description

The function is the following: https://github.com/DiamondLightSource/httomo/blob/7842bae27c1777545279aa36e8c10d9c4eeb489f/httomo/ui_layer.py#L241-L263

Pyright complains about the body of the second `if` statement, saying the following:
```
Type analysis indicates code is unreachable
```

This is understandable, because the type of `method` in the function signature is `MethodWrapper`, and so should never be `None`. Thus, the condition in the `if` statement will never evaluate to `True`, and the body will never be executed.

One way to easily fix this is by making `method` have type `Optional[MethodWrapper]`. However, some investigation into whether it should ever be `None` (and possibly investigation in further refactorings in other logic in the UI layer) may be wise before opting for the simplest fix.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.