Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 8, 2025

Summary

This PR updates type annotations for input parameters in public API functions throughout the codebase, changing list[T] to Collection[T] from collections.abc. This makes the API more flexible by accepting any collection type (tuples, sets, etc.) rather than requiring lists specifically.

Changes

Updated Input Parameter Annotations

src/rastr/create.py:

  • rasterize_gdf() - target_cols parameter
  • _validate_columns_exist() - target_cols parameter
  • _validate_columns_numeric() - target_cols parameter

Why This Matters

Before this change, users were required to pass lists to these functions:

# Had to use a list
rasterize_gdf(gdf, raster_meta=meta, target_cols=["value1", "value2"])

Now users can pass any collection type:

# Can now use tuple
rasterize_gdf(gdf, raster_meta=meta, target_cols=("value1", "value2"))

# Or set
rasterize_gdf(gdf, raster_meta=meta, target_cols={"value"})

This is particularly useful when columns are provided dynamically or come from other sources that naturally produce tuples or sets.

What Wasn't Changed

  • Return types that specify list[...] remain unchanged since they indicate the concrete type being returned by the function, not the types accepted as inputs.
  • Internal (underscore-prefixed) functions like _recursive_eval() were not changed as they are not part of the public API.

Testing

  • Added 2 new tests verifying that tuples and sets work as input parameters for public API functions
  • All existing tests pass
  • Linter checks pass

Fixes #129

Original prompt

This section details on the original issue you should resolve

<issue_title>Broaden type annotations for list to Collection etc.</issue_title>
<issue_description>Basically anywhere in the codebase where an input argument is annotated as list we should change it to Collection from collections.abc. And test it accordingly - e.g. using a tuple instead of a list</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #129

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@Copilot Copilot AI changed the title [WIP] Update type annotations from list to Collection Broaden type annotations from list to Collection for input parameters Oct 8, 2025
@Copilot Copilot AI requested a review from nathanjmcdougall October 8, 2025 23:06
Copilot finished work on behalf of nathanjmcdougall October 8, 2025 23:06
@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review October 8, 2025 23:19
@Copilot Copilot AI requested a review from nathanjmcdougall October 8, 2025 23:26
Copilot finished work on behalf of nathanjmcdougall October 8, 2025 23:26
@t-t-sonarqube
Copy link

t-t-sonarqube bot commented Oct 9, 2025

@nathanjmcdougall nathanjmcdougall marked this pull request as ready for review October 9, 2025 00:13
@b-j-karl b-j-karl merged commit 98d2a27 into develop Oct 10, 2025
15 of 29 checks passed
@b-j-karl b-j-karl deleted the copilot/broaden-type-annotations-collection branch October 10, 2025 02:52
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.

Broaden type annotations for list to Collection etc.

3 participants