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

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

Closed
glensc opened this issue Jan 23, 2022 · 2 comments

Comments

@glensc
Copy link
Contributor

glensc commented Jan 23, 2022

The problem

Such error has emerged: Taxel/PlexTraktSync#740

$ python -c "from requests_cache import CachedSession"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/python-3.9.10/lib/python3.9/site-packages/requests_cache/__init__.py", line 43, in <module>
    from .backends import *
  File "/python-3.9.10/lib/python3.9/site-packages/requests_cache/backends/__init__.py", line 8, in <module>
    from .base import BaseCache, BaseStorage
  File "/python-3.9.10/lib/python3.9/site-packages/requests_cache/backends/base.py", line 18, in <module>
    from ..serializers import init_serializer
  File "/python-3.9.10/lib/python3.9/site-packages/requests_cache/serializers/__init__.py", line 6, in <module>
    from .preconf import (
  File "/python-3.9.10/lib/python3.9/site-packages/requests_cache/serializers/preconf.py", line 26, in <module>
    base_stage = CattrStage()  #: Base stage for all serializer pipelines
  File "/python-3.9.10/lib/python3.9/site-packages/requests_cache/serializers/cattrs.py", line 32, in __init__
    self.converter = init_converter(factory)
  File "/python-3.9.10/lib/python3.9/site-packages/requests_cache/serializers/cattrs.py", line 68, in init_converter
    converter.register_structure_hook(
  File "/python-3.9.10/lib/python3.9/site-packages/cattr/converters.py", line 269, in register_structure_hook
    self._structure_func.register_cls_list([(cl, func)])
  File "/python-3.9.10/lib/python3.9/site-packages/cattr/dispatch.py", line 57, in register_cls_list
    self._single_dispatch.register(cls, handler)
  File "/usr/local/Cellar/python@3.9/3.9.10/Frameworks/Python.framework/Versions/3.9/lib/python3.9/functools.py", line 855, in register
    raise TypeError(
TypeError: Invalid first argument to `register()`. ForwardRef('CachedResponse') is not a class.

Environment

  • requests 2.27.1
  • requests-cache 0.8.1
  • cattrs 1.10.0
  • Python version: 3.9.9, 3.9.10, 3.10.0
  • Platform: macOS, Windows
@glensc glensc added the bug label Jan 23, 2022
@glensc
Copy link
Contributor Author

glensc commented Jan 23, 2022

Something odd is happening, started to work with 3.9.9, 3.10.1. I was just switching versions of python trying to figure out what version has the breakage. now upgraded to Python 3.9.10 and it's broken again. I compared site-packagers of two versions, did not see any obvious differences...

@JWCook
Copy link
Member

JWCook commented Jan 23, 2022

See #501; there was an unexpected breaking change in functools in python 3.10.2 and 3.9.10. A fix has been released in requests-cache 0.9.1.

@JWCook JWCook closed this as completed Jan 23, 2022
algitbot pushed a commit to alpinelinux/aports that referenced this issue Apr 16, 2022
Due to a breaking change in functools in python 3.10.1,
py3-requests-cache fails to build.

This has been fixed in v0.9.1

See: requests-cache/requests-cache#508
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants