python-us icon indicating copy to clipboard operation
python-us copied to clipboard

TypeError: str argument expected with fresh install on Python 3.10.1

Open InnovativeInventor opened this issue 3 years ago • 7 comments
trafficstars

On Python 3.10.1, a fresh pip install us yields this TypeError:

Python 3.10.1 (main, Dec 22 2021, 05:19:12) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import us
>>> us.states.lookup('maryland')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/max/.pyenv/versions/3.10.1/lib/python3.10/site-packages/us/states.py", line 86, in lookup
    val = jellyfish.metaphone(val)
TypeError: str argument expected

This is the output of pip freeze:

$ pip freeze
jellyfish==0.6.1
us==2.0.2

Is this a known issue?

InnovativeInventor avatar Jun 04 '22 23:06 InnovativeInventor

Huh, so I manually uninstalled jellyfish (since 0.6.1 looks old) and force-installed a more recent issue, which seemed to fix the issue. However, it looks like jellyfish is currently pinned to 0.6.1 for the latest release on PyPI because pip threw me this warning:

ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
us 2.0.2 requires jellyfish==0.6.1, but you have jellyfish 0.9.0 which is incompatible.

Perhaps it is worth bumping jellyfish to a more recent version?

InnovativeInventor avatar Jun 05 '22 00:06 InnovativeInventor

As a quick workaround to get the state information from the full name, I used this:

abbrev = states.mapping('name','abbr').get("Maryland")
state = states.lookup(abbrev)

and then you can access all the fields

>>> state.capital
'Annapolis'
>>> state.fips
'24'

The only gotcha is that the full name MUST be capitalized.

rgreinho avatar Jul 19 '22 01:07 rgreinho

@jcarbaugh is this project actively maintained? I'd be willing to help maintain this package, if that is welcome.

InnovativeInventor avatar Jul 19 '22 01:07 InnovativeInventor

I could also help if more maintainer help is needed.

rgreinho avatar Jul 19 '22 01:07 rgreinho

Perhaps it is worth bumping jellyfish to a more recent version?

As a clarification, since this is a library, I believe that this shouldn't be pinned to a specific jellyfish version, but a range. eg jellyfish>=0.8.0 not jellyfish==0.8.0

For instance, in my app I might have a requirement for jellyfish>=0.9.0, but if this library is hard pinned to jellyfish==0.8.0, then those two requirements are incompatible and I'm going to get that install error.

NickCrews avatar Sep 12 '22 00:09 NickCrews

Perhaps it is worth bumping jellyfish to a more recent version?

As a clarification, since this is a library, I believe that this shouldn't be pinned to a specific jellyfish version, but a range. eg jellyfish>=0.8.0 not jellyfish==0.8.0

For instance, in my app I might have a requirement for jellyfish>=0.9.0, but if this library is hard pinned to jellyfish==0.8.0, then those two requirements are incompatible and I'm going to get that install error.

Yeah, I agree with this. I assume jellyfish was pinned for some reason, but I do not know what that reason is.

InnovativeInventor avatar Sep 12 '22 16:09 InnovativeInventor

I think this is actually an upstream issue with jellyfish: https://github.com/jamesturk/jellyfish/issues/160

but updating to jellyfish>=0.9.0 DID fix it for me. So I'm not quite sure what version of jellyfish / version of python the bug began showing up. If anyone can clarify, please do

NickCrews avatar Sep 12 '22 17:09 NickCrews