Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from rss_parser import Parser throws error #42

Closed
ConstantineK opened this issue Jul 12, 2023 · 7 comments
Closed

from rss_parser import Parser throws error #42

ConstantineK opened this issue Jul 12, 2023 · 7 comments
Labels
bug Something isn't working dependencies Pull requests that update a dependency file

Comments

@ConstantineK
Copy link

Issue

The most basic example code I was running returned a - ImportError: cannot import name 'GenericModel' from 'pydantic.generics'
I simplified it down to from rss_parser import Parser - what am I doing wrong here?

Installing

A boring install of rss-parser, went fine.

(venv) (base) ck@DESKTOP-G0NAUG1:~$ pip install rss-parser
Collecting rss-parser
  Using cached rss_parser-1.0.0-py3-none-any.whl (24 kB)
Collecting xmltodict<0.14.0,>=0.13.0
  Using cached xmltodict-0.13.0-py2.py3-none-any.whl (10.0 kB)
Collecting pydantic>=1.6.1
  Using cached pydantic-2.0.2-py3-none-any.whl (359 kB)
Collecting pytest<8.0.0,>=7.1.2
  Using cached pytest-7.4.0-py3-none-any.whl (323 kB)
Collecting annotated-types>=0.4.0
  Using cached annotated_types-0.5.0-py3-none-any.whl (11 kB)
Collecting typing-extensions>=4.6.1
  Using cached typing_extensions-4.7.1-py3-none-any.whl (33 kB)
Collecting pydantic-core==2.1.2
  Using cached pydantic_core-2.1.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB)
Collecting iniconfig
  Using cached iniconfig-2.0.0-py3-none-any.whl (5.9 kB)
Collecting tomli>=1.0.0
  Using cached tomli-2.0.1-py3-none-any.whl (12 kB)
Collecting exceptiongroup>=1.0.0rc8
  Using cached exceptiongroup-1.1.2-py3-none-any.whl (14 kB)
Collecting pluggy<2.0,>=0.12
  Using cached pluggy-1.2.0-py3-none-any.whl (17 kB)
Collecting packaging
  Using cached packaging-23.1-py3-none-any.whl (48 kB)
Installing collected packages: xmltodict, typing-extensions, tomli, pluggy, packaging, iniconfig, exceptiongroup, pytest, pydantic-core, annotated-types, pydantic, rss-parser
Successfully installed annotated-types-0.5.0 exceptiongroup-1.1.2 iniconfig-2.0.0 packaging-23.1 pluggy-1.2.0 pydantic-2.0.2 pydantic-core-2.1.2 pytest-7.4.0 rss-parser-1.0.0 tomli-2.0.1 typing-extensions-4.7.1 xmltodict-0.13.0
WARNING: You are using pip version 22.0.4; however, version 23.1.2 is available.
You should consider upgrading via the '/home/ck/venv/bin/python -m pip install --upgrade pip' command.

Running

Running the most basic example

(venv) (base) ck@DESKTOP-G0NAUG1:~$ python
Python 3.8.13 (default, Mar 28 2022, 11:38:47)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from rss_parser import Parser
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/ck/venv/lib/python3.8/site-packages/rss_parser/__init__.py", line 1, in <module>
    from ._parser import Parser
  File "/home/ck/venv/lib/python3.8/site-packages/rss_parser/_parser.py", line 6, in <module>
    from rss_parser.models.rss import RSS
  File "/home/ck/venv/lib/python3.8/site-packages/rss_parser/models/rss.py", line 6, in <module>
    from rss_parser.models.channel import Channel
  File "/home/ck/venv/lib/python3.8/site-packages/rss_parser/models/channel.py", line 6, in <module>
    from rss_parser.models.image import Image
  File "/home/ck/venv/lib/python3.8/site-packages/rss_parser/models/image.py", line 4, in <module>
    from rss_parser.models.types.tag import Tag
  File "/home/ck/venv/lib/python3.8/site-packages/rss_parser/models/types/__init__.py", line 2, in <module>
    from rss_parser.models.types.tag import Tag
  File "/home/ck/venv/lib/python3.8/site-packages/rss_parser/models/types/tag.py", line 9, in <module>
    from pydantic.generics import GenericModel
ImportError: cannot import name 'GenericModel' from 'pydantic.generics' (/home/ck/venv/lib/python3.8/site-packages/pydantic/generics.py)
>>>
>>>
@dhvcc
Copy link
Owner

dhvcc commented Jul 14, 2023

That's very interesting, I can assure you I was testing the examples I put in readme, but there may be some missed stuff when doing a lot of refactoring. I'll look into it and will be back with an answer/fix today/tomorrow

@dhvcc
Copy link
Owner

dhvcc commented Jul 14, 2023

Or perhaps there's an update to pydantic, which removed this model from this module, but for my testing I was running an older version. Will check that too and possibly will add a conditional import to support both versions

@dhvcc
Copy link
Owner

dhvcc commented Jul 14, 2023

Sad that this issue came to my attention only after 2 days, I'll need to check notification settings

@dhvcc
Copy link
Owner

dhvcc commented Jul 14, 2023

Hey, @ConstantineK ,it seems like you have pydantic 2 installed, which is a major release with breaking changes. All works on pydantic<2
There was a mistake pinning pydantic version, so your pip didn't complain. Also the minimum version is 1.10, so this may not be suited for everybody at this point, they do change a lot of "magic" in their releases which I count on to work. Now releasing v1.1.0 with the dependecy pin
If you'd like to have a support for pydantic 2 let me know, but for now it's not a public release so bugs relating to it are to be expected I think
Hope this helps 👍

@dhvcc dhvcc added bug Something isn't working dependencies Pull requests that update a dependency file labels Jul 15, 2023
@ConstantineK
Copy link
Author

Makes total sense! Thanks for checking in on this.
Feel free to close this whenever you don't need it for tracking purposes.

@dhvcc
Copy link
Owner

dhvcc commented Jul 15, 2023

Sure, glad it helped 🙂

@dhvcc dhvcc closed this as completed Jul 15, 2023
@dhvcc
Copy link
Owner

dhvcc commented Oct 24, 2023

There's now a fallback to allow pydantic v2 usage without breaking the code in v1.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies Pull requests that update a dependency file
Projects
None yet
Development

No branches or pull requests

2 participants