Skip to content

Fix rasterio rowcol operation return type - #16352

Open
ryux1 wants to merge 1 commit into
python:mainfrom
ryux1:ryux1/rasterio-rowcol-op-return
Open

Fix rasterio rowcol operation return type#16352
ryux1 wants to merge 1 commit into
python:mainfrom
ryux1:ryux1/rasterio-rowcol-op-return

Conversation

@ryux1

@ryux1 ryux1 commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Closes #16342.

Preserve the default integer result while propagating a custom operation's return type through rowcol and index.

Agent used: OpenAI Codex.

@github-actions

This comment has been minimized.

Comment thread stubs/rasterio/rasterio/transform.pyi Outdated
**rpc_options: _GDALOption,
) -> tuple[float, float] | tuple[list[float], list[float]]: ...

@overload

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Astra thinks this is wrong:

index() must not propagate the callback’s return type. Its implementation explicitly returns tuple(int(val) for val in rowcol(...)). Even with a float-returning operation, index() returns integers. Separate its annotation from rowcol’s.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. TransformMethodsMixin.index() now keeps its integer return type and accepts callbacks returning ConvertibleToInt; only the rowcol() APIs propagate the callback return type. I also added regression assertions covering a float-returning callback for both paths and reran the targeted mypy, Pyright, stubtest, and multi-version checks.

@ryux1
ryux1 force-pushed the ryux1/rasterio-rowcol-op-return branch from 364da14 to afdb012 Compare September 6, 2026 04:27
@github-actions

github-actions Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

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.

[rasterio] transform.rowcol return typing possibly incorrect?

2 participants