Skip to content

Fix rasterio rowcol operation return type - #16352

Merged
srittau merged 3 commits into
python:mainfrom
ryux1:ryux1/rasterio-rowcol-op-return
Oct 28, 2026
Merged

srittau merged 3 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 Resolved
@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.

@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

This comment has been minimized.

@ryux1
ryux1 force-pushed the ryux1/rasterio-rowcol-op-return branch from c57c34c to 6f7eb6e Compare September 17, 2026 16:54
@ryux1

ryux1 commented Sep 17, 2026

Copy link
Copy Markdown
Contributor Author

Removed the added regression tests, kept the typing-only change, and rebased onto current main. The targeted rasterio stub suite passes across pre-commit, structure, Pyright, ty, pyrefly, and mypy.

@github-actions

This comment has been minimized.

@ryux1
ryux1 force-pushed the ryux1/rasterio-rowcol-op-return branch from 6f7eb6e to 08b853b Compare October 8, 2026 21:14
@ryux1

ryux1 commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Apologies for the delayed follow-up. I have rebased the branch onto current main while preserving the requested simplification and removal of the regression-test files. The targeted rasterio suite now passes locally across pre-commit, repository structure, Pyright, ty, pyrefly, and mypy. The updated branch is ready for another look when convenient.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

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

@thomas-maschler

Copy link
Copy Markdown
Contributor

@JelleZijlstra can we merge this?

@srittau
srittau merged commit 2b06f9d into python:main Oct 28, 2026
74 checks passed
@srittau

srittau commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

@thomas-maschler I think non-maintainers should also be able to review and approve PRs here. It definitely helps us if common contributors (who often have more experience than us for third-party libraries) do that. So please feel free to review and mark as "approved" if you think a PR is ready!

@thomas-maschler

Copy link
Copy Markdown
Contributor

@srittau happy to help. I didn't have the option to approve this PR.

@srittau

srittau commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

@thomas-maschler Too bad, I know it used to be possible, and the repository settings also allow it. Maybe that function has been disabled python org-wide. That said, a LGTM or similar will also do the job. (And your review above was certainly very helpful!)

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?

4 participants