robotpy / robotpy/mostrobotpy

[BUG]: mypy type errors in LEDPattern mapIndex

Open
#168 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
27
Forks
29
Avg merge
4d 6h
Merged PRs (30d)
12

Description

### Problem description

Here is the violating code snippet:

```python
def remapper(length: int, idx: int) -> int:
idx = int(idx)
splits = [
0,
int(length * self.right_rear_front_split),
int(length * self.halfway_split),
int(length * self.left_front_rear_split),
]
if splits[0] <= int(idx) < splits[1]:
return int(splits[1] - splits[0]) - idx
elif splits[2] <= int(idx) < splits[3]:
return int(splits[3] - splits[2]) - (idx - splits[2]) + splits[2]
else:
return int(idx)

forward = forward_pattern.mapIndex(remapper)
```

according to the type in the binding code the types expected by mapIndex are `typing.SupportsInt` so this is not expected

Here is error according to vscode

```
Argument of type "(length: int, idx: int) -> int" cannot be assigned to parameter "indexMapper" of type "(SupportsInt, SupportsInt) -> int" in function "mapIndex"
Type "(length: int, idx: int) -> int" is not assignable to type "(SupportsInt, SupportsInt) -> int"
Parameter 1: type "SupportsInt" is incompatible with type "int"
"SupportsInt" is not assignable to "int"
Parameter 2: type "SupportsInt" is incompatible with type "int"
"SupportsInt" is not assignable to "int"Pylance[reportArgumentType](https://github.com/microsoft/pyright/blob/main/docs/configuration.md#reportArgumentType)
```

### Operating System

Linux

### Installed Python Packages

```text
"numpy~=2.2",
"phoenix6~=25.3.1",
"robotpy-ctre~=2025.0.2",
"robotpy[apriltag]==2025.3.2.1",
"robotpy-rev~=2025.0.3",
"robotpy-wpilib-utilities==2025.1.0",
"photonlibpy~=2025.3.1",
"sleipnirgroup-choreolib~=2025.0.3",
```

### Reproducible example code

```text

```

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.