Narrow arbitrary index in a list
Open
narrowing
needs-discussion
typechecking
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 516
- PR merge metrics
- No merged PRs in 30d
Description
### Describe the Bug
In my class I have:
```python
def __init__(self, ...):
...
self.gps_time: Optional[datetime] = None
...
```
But in expression like following:
```python
(gps_seq[i].gps_time is None or gps_seq[i + 1].gps_time is None or gps_seq[i].gps_time >= gps_seq[i + 1].gps_time
```
It cannot "smart"-cast 'gps_seq[i].gps_time' and 'gps_seq[i + 1].gps_time' and consider that both values could be NoneType
I think more such cased should be handled using smart-casting variable, otherwise type checking is not pleasent at all
### Sandbox Link
_No response_
### (Only applicable for extension issues) IDE Information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.