Repository navigation
Description
Typos in render_shapes/render_points parameter names are silently swallowed
Environment: spatialdata-plot 0.3.4.dev (main, commit 5cfedc7), Python 3.13
Problem
render_shapes and render_points accept **kwargs to support datashader_reduction (a documented but kwargs-only parameter). As a side effect, all unknown keyword arguments are silently discarded with no warning or error.
sdata.pl.render_shapes("s", fill_alph=0.5) # typo for fill_alpha — silently ignored
sdata.pl.render_shapes("s", unknownparam=True) # unknown — silently ignored
sdata.pl.render_shapes("s", datashader_reductioon="mean") # typo in documented kwarg — silently ignoredThis makes typos in parameter names invisible: the user gets the default behaviour, not the behaviour they requested, with no feedback.
Minimal reproducible example
import matplotlib; matplotlib.use("Agg")
import matplotlib.pyplot as plt
import geopandas as gpd
from shapely.geometry import box
import spatialdata as sd
from spatialdata.models import ShapesModel
import spatialdata_plot
shapes = ShapesModel.parse(gpd.GeoDataFrame(
{"geometry": [box(0, 0, 1, 1)], "radius": [0.5]}, geometry="geometry"
))
sdata = sd.SpatialData(shapes={"s": shapes})
fig, ax = plt.subplots()
# All of these silently succeed — no TypeError, no warning
sdata.pl.render_shapes("s", typo_param=True).pl.show(ax=ax)
sdata.pl.render_shapes("s", fill_alph=0.5).pl.show(ax=ax) # intended: fill_alpha
sdata.pl.render_shapes("s", datashader_reductioon="max").pl.show(ax=ax) # typo in documented kwargExpected behaviour
TypeError: render_shapes() got unexpected keyword argument 'fill_alph'.
Did you mean 'fill_alpha'?
Actual behaviour
All three calls succeed silently. The user's typo is discarded and they get the default behaviour instead of the one they requested.
Fix sketch
After extracting the known kwargs (datashader_reduction, transfunc, vmin, vmax), validate that no unexpected keys remain:
known_kwargs = {"datashader_reduction", "transfunc", "vmin", "vmax"}
unexpected = set(kwargs) - known_kwargs
if unexpected:
raise TypeError(
f"render_shapes() got unexpected keyword argument(s): {sorted(unexpected)}"
)Alternatively, declare these parameters explicitly in the function signature so Python itself enforces the contract and IDEs provide autocomplete.
Triage tier: Tier 3
Activity
timtreis commentedon May 14, 2026
Already fixed on main. The render functions (
render_shapes,render_points,render_images,render_labelsinsrc/spatialdata_plot/pl/basic.py) no longer use**kwargs— they declare all accepted parameters explicitly, so Python itself enforces the contract. PR #652 (commit 29b1cc1) removed the last remaining**kwargs.Current behavior (verified on main):
This matches the "alternative" fix proposed in the issue (explicit signatures) and also gives "Did you mean …" suggestions courtesy of Python 3.12+.