Skip to content

Conversation

@mwtoews
Copy link
Contributor

@mwtoews mwtoews commented Aug 25, 2025

Attempts to use pathlike objects yields an unexpected errror:

from pathlib import Path

polygons = Path(DATA) / "polygons.shp"
stats = zonal_stats(polygons, raster)
# ValueError: Object is not a recognized source of Features

This PR allows pathlike vector sources.

Other changes:

  • Rewrite tests to use pathlib (rather than os.path)
  • Move pytest.ini to pyproject.toml, and use testpaths = ["tests"] instead of norecursedirs

dependencies = [
"affine",
"click >7.1",
"click >7.1, !=8.2.1",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This side-steps #307 and can be kept here as a fix or removed if there is a better fix.

]
testpaths = ["tests"]
# addopts = "--verbose -rf --ipdb --maxfail=1"

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks for keeping this pyproject.toml up to date!

features_iter = None
if isinstance(obj, str):
if isinstance(obj, (str, PathLike)):
obj = str(obj)
Copy link
Owner

Choose a reason for hiding this comment

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

👍 PathLike changes look great. Thanks!

@perrygeo perrygeo merged commit 6c092d5 into perrygeo:master Sep 2, 2025
4 checks passed
@mwtoews mwtoews deleted the use-pathlike branch September 2, 2025 18:22
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.

2 participants