TorrentHunt icon indicating copy to clipboard operation
TorrentHunt copied to clipboard

Invalid first argument to `register()`

Open panchalamitr opened this issue 3 years ago • 1 comments

I am using Python 3.10.5

After following all the steps, when I try to run following

python torrenthunt.py

I am getting an below error

TypeError: Invalid first argument to register(). ForwardRef('CachedResponse') is not a class.

Entire stacktrace is below

`(env) ➜ torrenthunt git:(main) ✗ python torrenthunt.py Traceback (most recent call last): File "/Users/amit/torrenthunt/torrenthunt.py", line 5, in

from src import *

File "/Users/amit/torrenthunt/src/init.py", line 2, in

from src.objs import config, dbSql

File "/Users/amit/torrenthunt/src/objs.py", line 5, in

import telebot, py1337x

File "/Users/amit/env/lib/python3.10/site-packages/py1337x/init.py", line 1, in

from py1337x.py1337x import py1337x

File "/Users/amit/env/lib/python3.10/site-packages/py1337x/py1337x.py", line 2, in

import requests_cache

File "/Users/amit/env/lib/python3.10/site-packages/requests_cache/init.py", line 43, in

from .backends import *

File "/Users/amit/env/lib/python3.10/site-packages/requests_cache/backends/init.py", line 8, in

from .base import BaseCache, BaseStorage

File "/Users/amit/env/lib/python3.10/site-packages/requests_cache/backends/base.py", line 18, in

from ..serializers import init_serializer

File "/Users/amit/env/lib/python3.10/site-packages/requests_cache/serializers/init.py", line 6, in

from .preconf import (

File "/Users/amit/env/lib/python3.10/site-packages/requests_cache/serializers/preconf.py", line 26, in

base_stage = CattrStage()  #: Base stage for all serializer pipelines

File "/Users/amit/env/lib/python3.10/site-packages/requests_cache/serializers/cattrs.py", line 32, in init

self.converter = init_converter(factory)

File "/Users/amit/env/lib/python3.10/site-packages/requests_cache/serializers/cattrs.py", line 67, in init_converter converter.register_structure_hook( File "/Users/amit/env/lib/python3.10/site-packages/cattr/converters.py", line 263, in register_structure_hook self._structure_func.register_cls_list([(cl, func)])

File "/Users/amit/env/lib/python3.10/site-packages/cattr/dispatch.py", line 57, in register_cls_list self._single_dispatch.register(cls, handler)

File "/opt/homebrew/Cellar/[email protected]/3.10.5/Frameworks/Python.framework/Versions/3.10/lib/python3.10/functools.py", line 856, in register raise TypeError( TypeError: Invalid first argument to register(). ForwardRef('CachedResponse') is not a class.`

Please help me if possible, how to get rid of this.

panchalamitr avatar Jul 09 '22 14:07 panchalamitr

This is a known issue with python>=3.10.2 and requests-cache<=0.9.0: https://github.com/requests-cache/requests-cache/issues/501

The solution is to update requests-cache to 0.9.1 or later.

JWCook avatar Jul 20 '22 00:07 JWCook

Am also on same problem with python 3.10.x

xon54 avatar Sep 22 '22 19:09 xon54

Updating requests-cache to latest version fixed the issue. Thanks to @JWCook

hemantapkh avatar Sep 23 '22 14:09 hemantapkh