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

Invalid first argument to register() #13

Closed
panchalamitr opened this issue Jul 9, 2022 · 3 comments
Closed

Invalid first argument to register() #13

panchalamitr opened this issue Jul 9, 2022 · 3 comments

Comments

@panchalamitr
Copy link

panchalamitr commented Jul 9, 2022

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/python@3.10/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.

@JWCook
Copy link

JWCook commented Jul 20, 2022

This is a known issue with python>=3.10.2 and requests-cache<=0.9.0: requests-cache/requests-cache#501

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

@xon54
Copy link

xon54 commented Sep 22, 2022

Am also on same problem with python 3.10.x

@hemantapkh
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants