@@ -25,24 +25,24 @@ def _pygris_func(name: str) -> Callable[..., Any]:
2525 func = getattr (pygris , name , None )
2626 if func is None :
2727 raise ImportError (
28- f"pygris does not expose '{ name } '. "
28+ f"pygris>=0.1.7 is required but does not expose '{ name } '. "
2929 "Upgrade with: pip install 'pypums[spatial]'"
3030 )
3131 return func
3232
3333
34- # Mapping: geography name -> (pygris_function , accepts_state, accepts_resolution).
35- _GEO_TO_PYGRIS : dict [str , tuple [str , bool , bool ]] = {
36- "state" : ("states" , False , True ),
37- "county" : ("counties" , True , True ),
38- "tract" : ("tracts" , True , False ),
39- "block group" : ("block_groups" , True , False ),
40- "place" : ("places" , True , False ),
41- "congressional district" : ("congressional_districts" , False , True ),
42- "zcta" : ("zctas" , False , False ),
43- "puma" : ("pumas" , True , False ),
44- "cbsa" : ("core_based_statistical_areas" , False , True ),
45- "csa" : ("combined_statistical_areas" , False , True ),
34+ # geography -> (pygris_func , accepts_state, accepts_resolution, requires_state)
35+ _GEO_TO_PYGRIS : dict [str , tuple [str , bool , bool , bool ]] = {
36+ "state" : ("states" , False , True , False ),
37+ "county" : ("counties" , True , True , False ),
38+ "tract" : ("tracts" , True , False , True ),
39+ "block group" : ("block_groups" , True , False , True ),
40+ "place" : ("places" , True , False , True ),
41+ "congressional district" : ("congressional_districts" , False , True , False ),
42+ "zcta" : ("zctas" , False , False , False ),
43+ "puma" : ("pumas" , True , False , True ),
44+ "cbsa" : ("core_based_statistical_areas" , False , True , False ),
45+ "csa" : ("combined_statistical_areas" , False , True , False ),
4646}
4747
4848
@@ -104,7 +104,14 @@ def _fetch_tiger_shapes(
104104 if entry is None :
105105 raise ValueError (f"No shapefile mapping for geography: { geography !r} " )
106106
107- func_name , accepts_state , accepts_resolution = entry
107+ func_name , accepts_state , accepts_resolution , requires_state = entry
108+
109+ if requires_state and state is None :
110+ raise ValueError (
111+ f"geography={ geography !r} requires a state parameter. "
112+ "Pass a state FIPS code, abbreviation, or name."
113+ )
114+
108115 func = _pygris_func (func_name )
109116
110117 kwargs : dict [str , Any ] = {
0 commit comments