Skip to content

Fix rasterio rowcol operation return type - #16352

Open
ryux1 wants to merge 2 commits into
python:mainfrom
ryux1:ryux1/rasterio-rowcol-op-return
Open

ryux1 wants to merge 2 commits 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
@ryux1
ryux1 force-pushed the ryux1/rasterio-rowcol-op-return branch from 364da14 to afdb012 Compare September 6, 2026 04:27
@github-actions

This comment has been minimized.

@thomas-maschler

Copy link
Copy Markdown
Contributor

I don't think all the extra @overload functions are necessary here.

Use _T = TypeVar("_T", default=int)

and for the existing rowcol() use

op: _RoundOperation[_T] | None = None and return tuple[_T, _T] | tuple[list[_T], list[_T]]

You can remove all the extra overloads. This should address the issue.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No need to include tests

@ryux1

ryux1 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Updated to use a defaulted type variable and removed the extra overloads as suggested. I also applied the same simplification to TransformerBase.rowcol; the existing deprecated overload is retained only for the precision parameter. The full targeted stubs/rasterio test suite passes locally.

@github-actions

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?

3 participants