Skip to content
1 change: 0 additions & 1 deletion stubs/rasterio/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Stubs-only helper modules with no runtime counterpart.
rasterio\._typing
rasterio\._affine_types

# Stubs-only type aliases referenced in signatures only.
rasterio\.merge\.MethodFunction
Expand Down
4 changes: 2 additions & 2 deletions stubs/rasterio/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "1.5.0"
version = "1.5.1"
upstream-repository = "https://github.com/rasterio/rasterio"
requires-python = ">=3.12"
dependencies = ["numpy>=2", "click>=8"]
dependencies = ["numpy>=2", "click>=8", "affine>=3"]
4 changes: 0 additions & 4 deletions stubs/rasterio/rasterio/_affine_types.pyi

This file was deleted.

3 changes: 2 additions & 1 deletion stubs/rasterio/rasterio/_base.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from types import TracebackType
from typing import Any, Final
from typing_extensions import Self, deprecated

from rasterio._affine_types import Affine
from affine import Affine as Affine
from rasterio._path import _ParsedPath, _UnparsedPath
from rasterio._typing import Colormap, CRSInput, _OpenOption
from rasterio.control import GroundControlPoint
Expand Down Expand Up @@ -55,6 +55,7 @@ class DatasetBase:
def start(self) -> None: ...
def stop(self) -> None: ...
def close(self) -> None: ...
def __del__(self) -> None: ...
@property
def closed(self) -> bool: ...
@property
Expand Down
2 changes: 1 addition & 1 deletion stubs/rasterio/rasterio/_io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ from typing import Any, BinaryIO, Final
from typing_extensions import Self, deprecated

import numpy as np
from affine import Affine as Affine
from numpy.typing import DTypeLike, NDArray
from rasterio._affine_types import Affine
from rasterio._base import DatasetBase
from rasterio._path import _ParsedPath, _UnparsedPath
from rasterio._typing import Colormap, CRSInput, Indexes, NumType, ShapeND, WindowInput, _GDALOption, _OpenOption
Expand Down
3 changes: 2 additions & 1 deletion stubs/rasterio/rasterio/_warp.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from collections.abc import Sequence
from typing import Any, Final

from affine import Affine as Affine
from numpy.typing import DTypeLike, NDArray
from rasterio._affine_types import Affine
from rasterio._io import DatasetReaderBase
from rasterio._typing import CRSInput, Geometry, Indexes, ShapeND, WindowInput, _GDALOption, _NestedScalar
from rasterio.control import GroundControlPoint
from rasterio.crs import CRS
from rasterio.dtypes import dtype_ranges as dtype_ranges
from rasterio.enums import Resampling
from rasterio.io import DatasetReader
from rasterio.rpc import RPC
Expand Down
1 change: 1 addition & 0 deletions stubs/rasterio/rasterio/errors.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class NodataShadowWarning(UserWarning): ...
class NotGeoreferencedWarning(UserWarning): ...
class TransformWarning(UserWarning): ...
class RPCError(ValueError): ...
class InvalidShapeError(RasterioError, ValueError): ...
class ShapeSkipWarning(UserWarning): ...
class GDALBehaviorChangeException(RuntimeError): ...
class GDALOptionNotImplementedError(RasterioError): ...
Expand Down
2 changes: 1 addition & 1 deletion stubs/rasterio/rasterio/features.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ from typing import Any, Final, overload
from typing_extensions import deprecated

import numpy as np
from affine import Affine as Affine
from numpy.typing import DTypeLike, NDArray
from rasterio._affine_types import Affine
from rasterio._typing import Geometry as Geometry
from rasterio.enums import MergeAlg as MergeAlg
from rasterio.io import DatasetReaderBase
Expand Down
2 changes: 1 addition & 1 deletion stubs/rasterio/rasterio/io.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ from types import TracebackType
from typing import Any, Final
from typing_extensions import Self, deprecated

from affine import Affine as Affine
from numpy.typing import DTypeLike
from rasterio._affine_types import Affine
from rasterio._filepath import FilePathBase as FilePathBase
from rasterio._io import (
BufferedDatasetWriterBase as BufferedDatasetWriterBase,
Expand Down
2 changes: 1 addition & 1 deletion stubs/rasterio/rasterio/mask.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import logging
from collections.abc import Iterable
from typing import Any, Final

from affine import Affine as Affine
from numpy.typing import NDArray
from rasterio._affine_types import Affine
from rasterio._typing import Geometry
from rasterio.errors import WindowError as WindowError
from rasterio.features import geometry_mask as geometry_mask, geometry_window as geometry_window
Expand Down
2 changes: 1 addition & 1 deletion stubs/rasterio/rasterio/merge.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ from collections.abc import Callable, Sequence
from typing import Any, Final, Literal, TypeAlias, overload
from typing_extensions import deprecated

from affine import Affine as Affine
from numpy.typing import DTypeLike, NDArray
from rasterio._affine_types import Affine
from rasterio.enums import Resampling
from rasterio.io import DatasetReaderBase

Expand Down
4 changes: 2 additions & 2 deletions stubs/rasterio/rasterio/plot.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import logging
from collections.abc import Mapping, Sequence
from typing import Any, Final, Literal

from affine import Affine as Affine
from numpy.typing import NDArray
from rasterio._affine_types import Affine
from rasterio.io import DatasetReader as DatasetReader
from rasterio.transform import guard_transform as guard_transform

Expand All @@ -25,7 +25,7 @@ def show(
title: str | None = None,
transform: Affine | None = None,
percent_range: tuple[float, float] | None = None,
adjust: bool = True,
adjust: bool = False,
**kwargs: Any,
) -> Any: ...
def plotting_extent(
Expand Down
4 changes: 4 additions & 0 deletions stubs/rasterio/rasterio/serde.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from functools import singledispatch

@singledispatch
def to_json(obj: object) -> object: ...
Comment on lines +2 to +4

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.

What you about adding TypeVar?

Suggested change
@singledispatch
def to_json(obj: object) -> object: ...
from typing import TypeVar
_T = TypeVar("_T)
@singledispatch
def to_json(obj: _T) -> _T: ...

@jack-volantautonomy jack-volantautonomy Aug 14, 2026

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.

This does seem like it would be the correct fix, but @singledispatch is already typed in typeshed and it handles the generic side of things as it is a generic function:

def singledispatch(func: Callable[..., _T]) -> _SingleDispatchCallable[_T]: ...

I did originally think about doing this in this discussion thread, but after looking deeper it was the incorrect change. #16180 (comment)

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.

Effectively whatever we type it as, the @singledispatch will collapse it to an object anyway if you look into it.

2 changes: 1 addition & 1 deletion stubs/rasterio/rasterio/stack.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import os
from collections.abc import Sequence
from typing import Any, Final

from affine import Affine as Affine
from numpy.typing import DTypeLike, NDArray
from rasterio._affine_types import Affine
from rasterio.enums import Resampling
from rasterio.io import DatasetReaderBase

Expand Down
2 changes: 1 addition & 1 deletion stubs/rasterio/rasterio/transform.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ from collections.abc import Callable, Sequence
from typing import Final, Literal, TypeAlias, overload
from typing_extensions import Self, deprecated

from rasterio._affine_types import Affine as Affine
from affine import Affine as Affine
from rasterio._transform import GCPTransformerBase, RPCTransformerBase
from rasterio._typing import _GDALOption
from rasterio.control import GroundControlPoint
Expand Down
3 changes: 2 additions & 1 deletion stubs/rasterio/rasterio/warp.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ from collections.abc import Mapping, Sequence
from typing import Any, Final, TypeAlias, overload
from typing_extensions import deprecated

from affine import Affine as Affine
from numpy.typing import ArrayLike, NDArray
from rasterio._affine_types import Affine
from rasterio._typing import CRSInput, Geometry, _GDALOption
from rasterio.control import GroundControlPoint
from rasterio.enums import Resampling
Expand Down Expand Up @@ -60,6 +60,7 @@ def reproject(
resampling: Resampling = ...,
num_threads: int = 1,
init_dest_nodata: bool = True,
tolerance: float = 0.125,
warp_mem_limit: int = 0,
src_geoloc_array: NDArray[Any] | None = None,
**kwargs: _GDALOption,
Expand Down
2 changes: 1 addition & 1 deletion stubs/rasterio/rasterio/windows.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ from collections.abc import Callable, Sequence
from typing import Any, TypeAlias, overload
from typing_extensions import Self, deprecated

from affine import Affine as Affine
from numpy.typing import NDArray
from rasterio._affine_types import Affine
from rasterio.errors import RasterioDeprecationWarning as RasterioDeprecationWarning, WindowError as WindowError

_Bounds: TypeAlias = tuple[float, float, float, float]
Expand Down