@@ -90,25 +90,26 @@ def __init__(
9090 ** kwargs : Any ,
9191 ):
9292 # Stat-first: derive geom from stat's default
93- if stat is not None :
94- stat_ref = _lookup_stat (stat )
95- if isinstance (stat_ref , type ):
96- geom = stat_ref .DEFAULT_PARAMS .get ("geom" , "blank" )
97- else :
98- geom = stat_ref .params .get ("geom" , "blank" )
99- # Forward stat instance's kwargs to the geom
100- if mapping is None and data is None and not kwargs :
101- mapping = stat_ref ._raw_kwargs .get ("mapping" )
102- data = stat_ref ._raw_kwargs .get ("data" )
103- kwargs = {
104- k : v
105- for k , v in stat_ref ._raw_kwargs .items ()
106- if k not in ("mapping" , "data" )
107- }
108-
10993 if geom is None :
110- geom = "blank"
94+ if stat is not None :
95+ stat_ref = _lookup_stat (stat )
96+ if isinstance (stat_ref , type ):
97+ geom = stat_ref .DEFAULT_PARAMS .get ("geom" , "blank" )
98+ else :
99+ geom = stat_ref .params .get ("geom" , "blank" )
100+ # Forward stat instance's kwargs to the geom
101+ if mapping is None and data is None and not kwargs :
102+ mapping = stat_ref ._raw_kwargs .get ("mapping" )
103+ data = stat_ref ._raw_kwargs .get ("data" )
104+ kwargs = {
105+ k : v
106+ for k , v in stat_ref ._raw_kwargs .items ()
107+ if k not in ("mapping" , "data" )
108+ }
109+ else :
110+ geom = "blank"
111111
112+ geom = cast ("geom | type[geom] | str" , geom )
112113 _geom = _resolve_geom (geom , mapping , data , kwargs )
113114 _stat = _resolve_stat (stat , _geom )
114115 _pos = _resolve_position (position , _geom )
0 commit comments