jaraco / inflect

Correctly generate plurals, ordinals, indefinite articles; convert numbers to words
https://pypi.org/project/inflect
MIT License
957 stars 107 forks source link

Incompatible with latest release of pydantic (v2) #187

Closed jennifer-richards closed 1 year ago

jennifer-richards commented 1 year ago

Version 2 of pydantic, which introducesbreaking changes, was just released to pypi. It seems that inflect is not compatible. Need to pin the version requirement for inflect's dependency.

As a workaround, we're just locally pinning our pydantic to < 2.

fyi, we're seeing

  File "[...]/python3.9/site-packages/inflect/__init__.py", line 77, in <module>
    from pydantic.typing import Annotated
ImportError: cannot import name 'Annotated' from 'pydantic.typing' ([...]/python3.9/site-packages/pydantic/typing.py)
biscuit314 commented 1 year ago

I am getting the same error: Python 3.11 I should have come here first - banging my head for over an hour. I pinned my setup.py to an earlier version of inflect.

MrRoiz commented 1 year ago

We had the same issue some hours ago, the only way to solve it was to force to install an specific version of pydantic (1 .10.10)

101med commented 1 year ago

In the file "inflect/inflect/init.py" on line 77, changing from pydantic.typing import Annotated to from typing import Annotated fixed it

tarudesu commented 1 year ago

So, have the problem been fixed or not? I still manage with this :(

dmalan commented 1 year ago

@tarudesu, if using a requirements.txt file, changing it to include

inflect==6.0.4
pydantic<2

should fix in the meantime, per @jennifer-richards!

Sirisha20202 commented 1 year ago

can any one hlep me in how to fix this bug

jaraco commented 1 year ago

The 6.0.5 and 6.1.0 releases should include the pin, as a workaround for the issue. I've re-opened this issue to track a more durable solution as well.

jaraco commented 1 year ago

In #191, I've started work on supporting Pydantic 2, including addressing the broken import. Now just need to figure out if the failing tests can be fixed.