walkerke / pygris

Use US Census shapefiles in Python (port of the R tigris package)
https://walker-data.com/pygris
MIT License
113 stars 16 forks source link

validate_state fails when supplying state fips code #17

Open sebastianrowan opened 9 months ago

sebastianrowan commented 9 months ago

An error is thrown when supplying a state fips code as the state argument for pygris.counties() and other functions that call validate_state().

>>> pygris.counties(33, year = 2020)

  File "PATH\Lib\site-packages\pygris\enumeration_units.py", line 92, in counties
    valid_state = [validate_state(x) for x in state]
                   ^^^^^^^^^^^^^^^^^
  File "PATH\Lib\site-packages\pygris\helpers.py", line 81, in validate_state
    state = state.lower()
            ^^^^^^^^^^^
AttributeError: 'int' object has no attribute 'lower'

validate_state() calls state.lower() before checking if state is numeric, causing this error. This could be solved be moving the numeric check to the top of validate_state.