pygris icon indicating copy to clipboard operation
pygris copied to clipboard

validate_state fails when supplying state fips code

Open sebastianrowan opened this issue 1 year ago • 0 comments

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.

sebastianrowan avatar Feb 05 '24 16:02 sebastianrowan