Skip to content

Implement typing overloads for (matrix) multiplication#137

Open
kylebarron wants to merge 3 commits intorasterio:mainfrom
kylebarron:kyle/overloads-matmul
Open

Implement typing overloads for (matrix) multiplication#137
kylebarron wants to merge 3 commits intorasterio:mainfrom
kylebarron:kyle/overloads-matmul

Conversation

@kylebarron
Copy link

@kylebarron kylebarron commented Jan 28, 2026

Currently when performing multiplication and matrix multiplication, there is poor type hinting. Currently types are resolved as

Affine | NotImplementedType | tuple[Unknown, Unknown] | tuple[Unknown, Unknown, Unbound | Unknown] | Unknown
image

(the gray text is inlay hints, meaning those are the inferred types that the editor is showing)

With additional errors of:

Operator "*" not supported for types "Affine | NotImplementedType | tuple[Unknown, Unknown] | tuple[Unknown, Unknown, Unbound | Unknown]" and "tuple[Literal[5], Literal[6]]"
  Operator "*" not supported for types "tuple[Unknown, Unknown]" and "tuple[Literal[5], Literal[6]]"
  Operator "*" not supported for types "tuple[Unknown, Unknown, Unbound | Unknown]" and "tuple[Literal[5], Literal[6]]"Pylance[reportOperatorIssue](https://github.com/microsoft/pylance-release/blob/main/docs/diagnostics/reportOperatorIssue.md)

After this PR, types are inferred cleanly:

image

Happy to create tests for these if the PR sounds good and you want them. We could use https://github.com/davidfritzsche/pytest-mypy-testing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant